Skip to content

Instantly share code, notes, and snippets.

@pragtobgists
Created April 1, 2018 10:22
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/5feeb1c19d535519c58994ccb8192490 to your computer and use it in GitHub Desktop.
Save pragtobgists/5feeb1c19d535519c58994ccb8192490 to your computer and use it in GitHub Desktop.
Bunny
list = Enum.to_list(1..10_000)
map_fun = fn(i) -> [i, i * i] end
Bunny.eat(%{
"flat_map" => fn -> Enum.flat_map(list, map_fun) end,
"map.flatten" => fn -> list |> Enum.map(map_fun) |> List.flatten end
})
tobi@speedy ~/github/bunny $ mix run samples/eat.exs
Bunny will take care of that for you!
( Y)
( . .)
o(") (")
Operating System: Linux
CPU Information: Intel(R) Core(TM) i7-4790 CPU @ 3.60GHz
Number of Available Cores: 8
Available memory: 15.61 GB
Elixir 1.6.3
Erlang 20.2
Benchmark suite executing with the following configuration:
warmup: 2 s
time: 5 s
parallel: 1
inputs: none specified
Estimated total run time: 14 s
Benchmarking flat_map...
Benchmarking map.flatten...
Name ips average deviation median 99th %
flat_map 2.23 K 448.25 μs ±14.33% 430 μs 790 μs
map.flatten 1.17 K 857.84 μs ±21.57% 796 μs 1426.98 μs
Comparison:
flat_map 2.23 K
map.flatten 1.17 K - 1.91x slower
Bunny is done!
() ()
(* *)
o( 0 )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment