Mix.install([
{:benchee, "~> 1.3"}
])
defmodule Bench do
def run() do
list = Enum.map(1..10000, fn _ -> :rand.uniform(30000) end)
Benchee.run(
%{
"map then join" => fn -> list |> Enum.map(&Integer.to_string(&1)) |> Enum.join(", ") end,
"mapjoin" => fn -> list |> Enum.map_join(", ", &Integer.to_string(&1)) end
},
time: 10,
memory_time: 2
)
end
end
Bench.run()