Created
May 12, 2009 18:35
-
-
Save moonpolysoft/110644 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env escript | |
-mode(compile). | |
main([Size]) -> | |
B = bloom:new(list_to_integer(Size), 0.001), | |
{_, Keys} = lists:foldl(fun(_, {Last, Acc}) -> | |
Mod = succ(Last), | |
{Mod, [Mod|Acc]} | |
end, {"aaaaaaaa", []}, lists:seq(1,10000)), | |
Start = now_float(), | |
lists:foldl(fun(Key, Bloom) -> | |
bloom:add_element(Key, Bloom) | |
end, B, Keys), | |
End = now_float(), | |
io:format("bloomerl took ~ps~n", [End - Start]). | |
succ([]) -> | |
[]; | |
succ(Str) -> | |
succ_int(lists:reverse(Str), []). | |
succ_int([Char|Str], Acc) -> | |
if | |
Char >= $z -> succ_int(Str, [$a|Acc]); | |
true -> lists:reverse(lists:reverse([Char+1|Acc]) ++ Str) | |
end. | |
now_float() -> | |
time_to_epoch_float(now()). | |
time_to_epoch_float({Mega,Sec,Micro}) -> | |
Mega * 1000000 + Sec + Micro / 1000000. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
galva:bloomerl-read-only cliff$ ./bloom_test.escript 10000 | |
bloomerl took 1.3897240161895752s | |
galva:bloomerl-read-only cliff$ ./bloom_test.escript 100000 | |
bloomerl took 34.966973066329956s | |
galva:bloomerl-read-only cliff$ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment