2012-01-07 16:17:48 +00:00
|
|
|
-module(lsm_btree_merger_tests).
|
2012-01-06 21:56:23 +00:00
|
|
|
|
|
|
|
-ifdef(TEST).
|
|
|
|
-include_lib("proper/include/proper.hrl").
|
|
|
|
-include_lib("eunit/include/eunit.hrl").
|
|
|
|
-endif.
|
|
|
|
|
|
|
|
-compile(export_all).
|
|
|
|
|
|
|
|
merge_test() ->
|
|
|
|
|
2012-01-06 23:28:26 +00:00
|
|
|
file:delete("test1"),
|
|
|
|
file:delete("test2"),
|
|
|
|
file:delete("test3"),
|
|
|
|
|
2012-01-07 16:17:48 +00:00
|
|
|
{ok, BT1} = lsm_btree_writer:open("test1"),
|
2012-01-06 21:56:23 +00:00
|
|
|
lists:foldl(fun(N,_) ->
|
2012-01-07 16:17:48 +00:00
|
|
|
ok = lsm_btree_writer:add(BT1, <<N:128>>, <<"data",N:128>>)
|
2012-01-06 21:56:23 +00:00
|
|
|
end,
|
|
|
|
ok,
|
|
|
|
lists:seq(1,10000,2)),
|
2012-01-07 16:17:48 +00:00
|
|
|
ok = lsm_btree_writer:close(BT1),
|
2012-01-06 21:56:23 +00:00
|
|
|
|
|
|
|
|
2012-01-07 16:17:48 +00:00
|
|
|
{ok, BT2} = lsm_btree_writer:open("test2"),
|
2012-01-06 21:56:23 +00:00
|
|
|
lists:foldl(fun(N,_) ->
|
2012-01-07 16:17:48 +00:00
|
|
|
ok = lsm_btree_writer:add(BT2, <<N:128>>, <<"data",N:128>>)
|
2012-01-06 21:56:23 +00:00
|
|
|
end,
|
|
|
|
ok,
|
|
|
|
lists:seq(2,5001,1)),
|
2012-01-07 16:17:48 +00:00
|
|
|
ok = lsm_btree_writer:close(BT2),
|
2012-01-06 21:56:23 +00:00
|
|
|
|
|
|
|
|
2012-01-20 09:06:43 +00:00
|
|
|
{Time,{ok,Count}} = timer:tc(lsm_btree_merger, merge, ["test1", "test2", "test3", 10000, true]),
|
2012-01-06 21:56:23 +00:00
|
|
|
|
|
|
|
error_logger:info_msg("time to merge: ~p/sec (time=~p, count=~p)~n", [1000000/(Time/Count), Time/1000000, Count]),
|
|
|
|
|
|
|
|
ok.
|
|
|
|
|