Skip to content

Instantly share code, notes, and snippets.

@gootik
Last active October 6, 2017 14:27
Show Gist options
  • Save gootik/cf3a540137364a61caab3b2acea4f9b1 to your computer and use it in GitHub Desktop.
Save gootik/cf3a540137364a61caab3b2acea4f9b1 to your computer and use it in GitHub Desktop.
Testing map timing
-module(test).
-compile([export_all]).
map_time() ->
Map = #{a => true,
b => true,
c => true,
p => true,
e => true,
x => true},
TestList = [a, b, c, c, d, a, a, b, c, c, d, a, a, b, c, c, d, a,
e, f, g, h, i, i, j, k, c, c, l, l, a, p, o, m, d, a],
Counter = lists:seq(0, 20000),
Start = os:timestamp(),
[begin
lists:filter(
fun(I) ->
maps:is_key(I, Map)
end, TestList)
end || _ <- Counter],
End = os:timestamp(),
io:format(user, "Took ~pms to run~n", [timer:now_diff(End,Start) / 1000]).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment