Skip to content

Instantly share code, notes, and snippets.

@ghatighorias
Created January 30, 2017 11:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ghatighorias/2332ddbb0d40cfdda95c80f780341858 to your computer and use it in GitHub Desktop.
Save ghatighorias/2332ddbb0d40cfdda95c80f780341858 to your computer and use it in GitHub Desktop.
defmodule Benchmark do
def run do
map_fun = fn(element) -> element + 1 end
inputs = %{
"small" => Enum.to_list(1..10_000),
"medium" => Enum.to_list(1..100_000),
"big" => Enum.to_list(1..1_000_000),
"verybig" => Enum.to_list(1..5_000_000)
}
Benchee.run(%{
"tail-recursive" => fn(list) -> MyMap.map_tco(list, map_fun) end,
"std-lib map" => fn(list) -> Enum.map(list, map_fun) end,
"body-recursive" => fn(list) -> MyMap.map_body(list, map_fun) end
}, time: 20, warmup: 10, inputs: inputs)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment