Benchee reduction counting example
This file contains 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
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 | |
}, | |
reduction_time: 2 | |
) |
This file contains 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
Operating System: Linux | |
CPU Information: AMD Ryzen 9 5900X 12-Core Processor | |
Number of Available Cores: 24 | |
Available memory: 31.27 GB | |
Elixir 1.13.3 | |
Erlang 24.2.1 | |
Benchmark suite executing with the following configuration: | |
warmup: 2 s | |
time: 5 s | |
memory time: 0 ns | |
reduction time: 2 s | |
parallel: 1 | |
inputs: none specified | |
Estimated total run time: 18 s | |
Benchmarking flat_map ... | |
Benchmarking map.flatten ... | |
Name ips average deviation median 99th % | |
flat_map 3.52 K 283.95 μs ±10.98% 279.09 μs 500.28 μs | |
map.flatten 2.26 K 441.58 μs ±20.43% 410.51 μs 680.60 μs | |
Comparison: | |
flat_map 3.52 K | |
map.flatten 2.26 K - 1.56x slower +157.64 μs | |
Reduction count statistics: | |
Name Reduction count | |
flat_map 65.01 K | |
map.flatten 124.52 K - 1.92x reduction count +59.51 K | |
**All measurements for reduction count were the same** |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment