Skip to content

Instantly share code, notes, and snippets.

@koga1020
Created June 23, 2022 09:42
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 koga1020/fa926bfdb3196ce8165a5e3797d52d55 to your computer and use it in GitHub Desktop.
Save koga1020/fa926bfdb3196ce8165a5e3797d52d55 to your computer and use it in GitHub Desktop.
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