Created
June 23, 2022 09:42
-
-
Save koga1020/fa926bfdb3196ce8165a5e3797d52d55 to your computer and use it in GitHub Desktop.
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, "~> 1.0", only: :dev}, | |
{:flow, "~> 1.2.0"} | |
]) | |
mapper = fn number -> number * number end | |
Benchee.run(%{ | |
"enum" => fn -> 1..1_0000_000 |> Enum.map(mapper) |> Enum.sum() end, | |
"flow" => fn -> 1..1_0000_000 |> Flow.from_enumerable() |> Flow.map(mapper) |> Enum.sum() end | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment