Skip to content

Instantly share code, notes, and snippets.

@pragtobgists
Created December 1, 2016 14:21
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 pragtobgists/d3cd52cb68c935c39f6ca6b3c9cf1511 to your computer and use it in GitHub Desktop.
Save pragtobgists/d3cd52cb68c935c39f6ca6b3c9cf1511 to your computer and use it in GitHub Desktop.
New benchee API
list = Enum.to_list(1..10_000)
map_fun = fn(i) -> [i, i * i] end
Benchee.run(%{
"flat_map" => fn -> Enum.flat_map(list, map_fun) end,
"map.flatten" => fn -> list |> Enum.map(map_fun) |> List.flatten end
},
formatters: [
&Benchee.Formatters.HTML.output/1,
&Benchee.Formatters.Console.output/1
],
html: [file: "samples_output/flat_map.html"],
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment