Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Time insert.

  • Loading branch information...
commit ce98f1c016adcc7233927086d9bf1190ae33c35f 1 parent 0e27129
@knutin authored
Showing with 12 additions and 5 deletions.
  1. +12 −5 src/btrie.erl
View
17 src/btrie.erl
@@ -13,6 +13,8 @@
new() ->
<<?MAGIC>>.
+size_mb(B) ->
+ size(B) / 1024 / 1024.
node(K, Value, Children) ->
<<K:8,
@@ -90,8 +92,6 @@ insert(<<NodeK,
(size(NewChildren)):32/integer, NewChildren/binary, Siblings/binary>>
end.
-%% insert(B, K, V) ->
-%% io:format("b: ~p~nk: ~p~nv: ~p~n", [B, K, V]).
@@ -104,14 +104,11 @@ delete(<<K,
<<K>>) ->
<<K, 0:32, ChildrenSize:32, Children/binary, Siblings/binary>>;
-%%Siblings;
-
delete(<<K,
ValueSize:32/integer, Value:ValueSize/binary,
ChildrenSize:32/integer, Children:ChildrenSize/binary, Siblings/binary>>,
<<K, KeyRest/binary>>) ->
NewChildren = delete(Children, KeyRest),
-
<<K,
ValueSize:32/integer, Value/binary,
(size(NewChildren)):32/integer, NewChildren/binary, Siblings/binary>>;
@@ -167,6 +164,16 @@ delete_test() ->
?assertEqual(not_found, find(delete(from_list(L), <<"abc">>), <<"abc">>)).
+size_test() ->
+ NumKeys = 10000,
+
+ Start = 10000000,
+ L = lists:map(fun (I) -> {list_to_binary(integer_to_list(I)), <<0>>} end,
+ lists:seq(Start, Start + NumKeys)),
+ StartTime = now(),
+ B = from_list(L),
+ timer:now_diff(now(), StartTime) / 1000.
+
%%

0 comments on commit ce98f1c

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