Created
May 3, 2024 12:58
-
-
Save Stamates/5ff14f0baf7a63ec9ad412082ce08637 to your computer and use it in GitHub Desktop.
Benchee 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
Mix.install [:benchee] | |
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 | |
}, | |
time: 10, | |
memory_time: 2 | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment