Created
January 15, 2021 06:27
-
-
Save J3RN/51db9b64e51e83276a7bdb17bc720a92 to your computer and use it in GitHub Desktop.
Benchmark of different methods of map transformation
This file contains hidden or 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
sample = Enum.map(1..1000, &{&1, &1}) |> Map.new() | |
Benchee.run(%{ | |
"maps:map" => fn -> :maps.map(fn _k, v -> v * 2 end, sample) end, | |
"Map.new" => fn -> Map.new(sample, fn {k, v} -> {k, v * 2} end) end, | |
"for" => fn -> for {k, v} <- sample, into: %{}, do: {k, v * 2} end | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
My results: