Created
June 10, 2022 19:56
-
-
Save nickva/708d0fd54cc7849dfd56ed0d0e508450 to your computer and use it in GitHub Desktop.
Sorting an already sorted list in 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
% ./erlperf \ | |
'runner(Unsorted) -> lists:sort(Unsorted).' \ | |
--init_runner '[{rand:uniform(), I} || I <- lists:seq(1,500)].' \ | |
'runner(Sorted) -> lists:sort(Sorted).' \ | |
--init_runner 'lists:sort([{rand:uniform(), I} || I <- lists:seq(1,500)]).' | |
Code || QPS Time Rel | |
runner(Sorted) -> lists:sort(Sorted). 1 69223 14446 ns 100% | |
runner(Unsorted) -> lists:sort(Unsorted). 1 7158 140 us 10% | |
% ./erlperf \ | |
'runner(Unsorted) -> lists:sort(Unsorted).' \ | |
--init_runner '[{rand:uniform(), I} || I <- lists:seq(1,1000)].' \ | |
'runner(Sorted) -> lists:sort(Sorted).' \ | |
--init_runner 'lists:sort([{rand:uniform(), I} || I <- lists:seq(1,1000)]).' | |
Code || QPS Time Rel | |
runner(Sorted) -> lists:sort(Sorted). 1 30532 32752 ns 100% | |
runner(Unsorted) -> lists:sort(Unsorted). 1 2995 334 us 9% |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment