Created
December 27, 2009 14:28
-
-
Save cooldaemon/264286 to your computer and use it in GitHub Desktop.
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(fold). | |
-author('[email protected]'). | |
-export([test/1]). | |
test(Max) -> | |
lists:map( | |
fun (F) -> | |
benchmark(fun () -> | |
F(fun (N, Acc) -> N + Acc end, 0, lists:seq(1, Max)) | |
end) | |
end, | |
[fun lists:foldl/3, fun lists:foldr/3] | |
). | |
benchmark(F) -> | |
lists:foreach(fun statistics/1, [runtime, wall_clock]), | |
Result = F(), | |
Times = lists:map( | |
fun (Type) -> {_, T} = statistics(Type), T end, | |
[runtime, wall_clock] | |
), | |
{Result, Times}. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment