Created
February 4, 2015 23:22
-
-
Save twonds/d0474b368ff2a55503db 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
-module(ets_update). | |
-compile(export_all). | |
setup() -> | |
ets:new(test, [public, named_table]), | |
ets:insert(test, {test, 0}). | |
lookup(N) -> | |
ets:lookup(test, N). | |
update(N) -> | |
ets:update_counter(test, N, 1). | |
teardown() -> | |
ets:delete(test). |
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
-module(ets_update_test). | |
-compile(export_all). | |
test() -> | |
test(100000). | |
test(N) -> | |
ets_update:setup(), | |
T = do_test(N,fun() -> | |
ets:update_counter(test, test, 1) | |
end), | |
io:format("Ets call ~p ~n", [T]), | |
LT = do_test(N, fun() -> | |
ets_update:update(test) | |
end), | |
io:format("Module -> Ets call ~p ~n", [LT]), | |
ets_update:teardown(), | |
ok. | |
do_test(N, Fun) -> | |
Time = 0, | |
lists:foldl(fun(_X, Acc) -> | |
{T, _Ret} = timer:tc(Fun), | |
T + Acc | |
end, Time, lists:seq(1, N)). |
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
27> c(ets_update). | |
{ok,ets_update} | |
28> c(ets_update_test). | |
{ok,ets_update_test} | |
29> ets_update_test:test(). | |
Ets call 17951 | |
Module -> Ets call 18601 | |
ok | |
30> ets_update_test:test(). | |
Ets call 19645 | |
Module -> Ets call 18700 | |
ok | |
31> ets_update_test:test(). | |
Ets call 18405 | |
Module -> Ets call 17923 | |
ok | |
32> ets_update_test:test(). | |
Ets call 18116 | |
Module -> Ets call 16552 | |
ok | |
33> ets_update_test:test(). | |
Ets call 20134 | |
Module -> Ets call 20120 | |
ok | |
34> ets_update_test:test(). | |
Ets call 19054 | |
Module -> Ets call 18398 | |
ok | |
35> ets_update_test:test(100). | |
Ets call 36 | |
Module -> Ets call 34 | |
ok | |
36> ets_update_test:test(100). | |
Ets call 36 | |
Module -> Ets call 31 | |
ok | |
37> ets_update_test:test(100). | |
Ets call 35 | |
Module -> Ets call 34 | |
ok | |
38> ets_update_test:test(10000000). | |
Ets call 2075998 | |
Module -> Ets call 1971149 | |
ok | |
39> ets_update_test:test(10000000). | |
Ets call 2001510 | |
Module -> Ets call 2174899 | |
ok |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment