Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Time insert.

  • Loading branch information...
commit ce98f1c016adcc7233927086d9bf1190ae33c35f 1 parent 0e27129
Knut Nesheim authored

Showing 1 changed file with 12 additions and 5 deletions. Show diff stats Hide diff stats

  1. +12 5 src/btrie.erl
17 src/btrie.erl
@@ -13,6 +13,8 @@
13 13 new() ->
14 14 <<?MAGIC>>.
15 15
  16 +size_mb(B) ->
  17 + size(B) / 1024 / 1024.
16 18
17 19 node(K, Value, Children) ->
18 20 <<K:8,
@@ -90,8 +92,6 @@ insert(<<NodeK,
90 92 (size(NewChildren)):32/integer, NewChildren/binary, Siblings/binary>>
91 93 end.
92 94
93   -%% insert(B, K, V) ->
94   -%% io:format("b: ~p~nk: ~p~nv: ~p~n", [B, K, V]).
95 95
96 96
97 97
@@ -104,14 +104,11 @@ delete(<<K,
104 104 <<K>>) ->
105 105 <<K, 0:32, ChildrenSize:32, Children/binary, Siblings/binary>>;
106 106
107   -%%Siblings;
108   -
109 107 delete(<<K,
110 108 ValueSize:32/integer, Value:ValueSize/binary,
111 109 ChildrenSize:32/integer, Children:ChildrenSize/binary, Siblings/binary>>,
112 110 <<K, KeyRest/binary>>) ->
113 111 NewChildren = delete(Children, KeyRest),
114   -
115 112 <<K,
116 113 ValueSize:32/integer, Value/binary,
117 114 (size(NewChildren)):32/integer, NewChildren/binary, Siblings/binary>>;
@@ -167,6 +164,16 @@ delete_test() ->
167 164 ?assertEqual(not_found, find(delete(from_list(L), <<"abc">>), <<"abc">>)).
168 165
169 166
  167 +size_test() ->
  168 + NumKeys = 10000,
  169 +
  170 + Start = 10000000,
  171 + L = lists:map(fun (I) -> {list_to_binary(integer_to_list(I)), <<0>>} end,
  172 + lists:seq(Start, Start + NumKeys)),
  173 + StartTime = now(),
  174 + B = from_list(L),
  175 + timer:now_diff(now(), StartTime) / 1000.
  176 +
170 177
171 178
172 179 %%

0 comments on commit ce98f1c

Please sign in to comment.
Something went wrong with that request. Please try again.