Skip to content

Instantly share code, notes, and snippets.

@pragtobgists
Created July 12, 2016 07:06
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/39686e4c09cc9cdef4b364847df2b9ce to your computer and use it in GitHub Desktop.
Save pragtobgists/39686e4c09cc9cdef4b364847df2b9ce to your computer and use it in GitHub Desktop.
Parallel benchee benchmark executing each job with a parallelity level of 2
list = Enum.to_list(1..10_000)
map_fun = fn(i) -> [i, i * i] end
Benchee.run(%{time: 3, parallel: 2}, %{
"flat_map" => fn -> Enum.flat_map(list, map_fun) end,
"map.flatten" => fn -> list |> Enum.map(map_fun) |> List.flatten end
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment