Created
December 7, 2016 11:45
-
-
Save maruks/0a2d5d92927b631d4231be615b115d61 to your computer and use it in GitHub Desktop.
GC benchmark ported to Erlang
This file contains hidden or 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(main). | |
-define(WINDOW_SIZE, 200000). | |
-define(MSG_COUNT, 1000000). | |
-define(MSG_SIZE, 1024). | |
-export([main/0]). | |
push_message(N) -> | |
Start = erlang:monotonic_time(), | |
Bin = list_to_binary(lists:duplicate(?MSG_SIZE, N rem 255)), | |
put(N, Bin), | |
Low = N - ?WINDOW_SIZE, | |
if | |
Low >= 0 -> erase(Low); | |
true -> nop | |
end, | |
Diff = erlang:monotonic_time() - Start, | |
erlang:convert_time_unit(Diff, native, millisecond). | |
push_all_messages(0, Time) -> | |
Time; | |
push_all_messages(Id, Time) -> | |
T = push_message(Id), | |
push_all_messages(Id - 1, max(Time, T)). | |
main() -> | |
MaxTime = push_all_messages(?MSG_COUNT, 0), | |
io:format("Worst push time ~p ~n",[MaxTime]). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment