From 299e8e6de3b878214a59d9067d5c9e55d091c4ba Mon Sep 17 00:00:00 2001 From: martinsumner Date: Tue, 20 Dec 2016 20:55:56 +0000 Subject: [PATCH] Initial phash test phash does not appear to be a potential causer of delay --- src/leveled_codec.erl | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/leveled_codec.erl b/src/leveled_codec.erl index ffb3f98..5344f53 100644 --- a/src/leveled_codec.erl +++ b/src/leveled_codec.erl @@ -469,4 +469,14 @@ stringcheck_test() -> ?assertMatch("Bucket", turn_to_string(<<"Bucket">>)), ?assertMatch("bucket", turn_to_string(bucket)). +%% Test below proved that the overhead of performing hashes was trivial +%% Maybe 5 microseconds per hash + +hashperf_test() -> + OL = lists:map(fun(_X) -> crypto:rand_bytes(8192) end, lists:seq(1, 10000)), + SW = os:timestamp(), + _HL = lists:map(fun(Obj) -> erlang:phash2(Obj) end, OL), + io:format(user, "10000 object hashes in ~w microseconds~n", + [timer:now_diff(os:timestamp(), SW)]). + -endif. \ No newline at end of file