Loop test
This commit is contained in:
parent
ef6df2387d
commit
87731a85f5
1 changed files with 30 additions and 30 deletions
|
@ -284,45 +284,46 @@ empty_bloom_test() ->
|
||||||
check_neg_hashes(BloomBin0, [0, 10, 100, 100000], {0, 0})).
|
check_neg_hashes(BloomBin0, [0, 10, 100, 100000], {0, 0})).
|
||||||
|
|
||||||
bloom_test() ->
|
bloom_test() ->
|
||||||
test_bloom(128),
|
test_bloom(128, 400),
|
||||||
test_bloom(64),
|
test_bloom(64, 400),
|
||||||
test_bloom(32),
|
test_bloom(32, 400),
|
||||||
test_bloom(16),
|
test_bloom(16, 400),
|
||||||
test_bloom(8).
|
test_bloom(8, 400).
|
||||||
|
|
||||||
test_bloom(N) ->
|
test_bloom(N, Runs) ->
|
||||||
HashList1 = get_hashlist(N),
|
ListOfHashLists =
|
||||||
HashList2 = get_hashlist(N),
|
lists:map(fun(_X) -> get_hashlist(N) end, lists:seq(1, Runs)),
|
||||||
HashList3 = get_hashlist(N),
|
|
||||||
HashList4 = get_hashlist(N),
|
|
||||||
|
|
||||||
SWa = os:timestamp(),
|
SWa = os:timestamp(),
|
||||||
BloomBin1 = create_bloom(HashList1),
|
ListOfBlooms =
|
||||||
BloomBin2 = create_bloom(HashList2),
|
lists:map(fun(HL) -> create_bloom(HL) end, ListOfHashLists),
|
||||||
BloomBin3 = create_bloom(HashList3),
|
|
||||||
BloomBin4 = create_bloom(HashList4),
|
|
||||||
TSa = timer:now_diff(os:timestamp(), SWa),
|
TSa = timer:now_diff(os:timestamp(), SWa),
|
||||||
|
|
||||||
SWb = os:timestamp(),
|
SWb = os:timestamp(),
|
||||||
check_all_hashes(BloomBin1, HashList1),
|
lists:foreach(fun(Nth) ->
|
||||||
check_all_hashes(BloomBin2, HashList2),
|
HL = lists:nth(Nth, ListOfHashLists),
|
||||||
check_all_hashes(BloomBin3, HashList3),
|
BB = lists:nth(Nth, ListOfBlooms),
|
||||||
check_all_hashes(BloomBin4, HashList4),
|
check_all_hashes(BB, HL)
|
||||||
|
end,
|
||||||
|
lists:seq(1, Runs)),
|
||||||
TSb = timer:now_diff(os:timestamp(), SWb),
|
TSb = timer:now_diff(os:timestamp(), SWb),
|
||||||
|
|
||||||
HashPool = get_hashlist(N * 2),
|
HashPool = get_hashlist(N * 2),
|
||||||
HashListOut1 = lists:sublist(lists:subtract(HashPool, HashList1), N),
|
ListOfMisses =
|
||||||
HashListOut2 = lists:sublist(lists:subtract(HashPool, HashList2), N),
|
lists:map(fun(HL) ->
|
||||||
HashListOut3 = lists:sublist(lists:subtract(HashPool, HashList3), N),
|
lists:sublist(lists:subtract(HashPool, HL), N)
|
||||||
HashListOut4 = lists:sublist(lists:subtract(HashPool, HashList4), N),
|
end,
|
||||||
|
ListOfHashLists),
|
||||||
|
|
||||||
SWc = os:timestamp(),
|
SWc = os:timestamp(),
|
||||||
C0 = {0, 0},
|
{Pos, Neg} =
|
||||||
C1 = check_neg_hashes(BloomBin1, HashListOut1, C0),
|
lists:foldl(fun(Nth, Acc) ->
|
||||||
C2 = check_neg_hashes(BloomBin2, HashListOut2, C1),
|
HL = lists:nth(Nth, ListOfMisses),
|
||||||
C3 = check_neg_hashes(BloomBin3, HashListOut3, C2),
|
BB = lists:nth(Nth, ListOfBlooms),
|
||||||
C4 = check_neg_hashes(BloomBin4, HashListOut4, C3),
|
check_neg_hashes(BB, HL, Acc)
|
||||||
{Pos, Neg} = C4,
|
end,
|
||||||
|
{0, 0},
|
||||||
|
lists:seq(1, Runs)),
|
||||||
FPR = Pos / (Pos + Neg),
|
FPR = Pos / (Pos + Neg),
|
||||||
TSc = timer:now_diff(os:timestamp(), SWc),
|
TSc = timer:now_diff(os:timestamp(), SWc),
|
||||||
|
|
||||||
|
@ -332,5 +333,4 @@ test_bloom(N) ->
|
||||||
[N, TSa, TSb, TSc, FPR]).
|
[N, TSa, TSb, TSc, FPR]).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-endif.
|
-endif.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue