Skip to content

Instantly share code, notes, and snippets.

View J3RN's full-sized avatar

Jonathan Arnett J3RN

View GitHub Profile
@J3RN
J3RN / map_benchmark.ex
Created January 15, 2021 06:27
Benchmark of different methods of map transformation
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
})
@J3RN
J3RN / naive performance
Created January 10, 2022 20:54
"optimizing" Gleam code
****** Process <0.91.0> -- 100.00 % of profiled time ***
FUNCTION CALLS % TIME [uS / CALLS]
-------- ----- ------- ---- [----------]
erl_eval:exprs/5 1 0.00 0 [ 0.00]
erl_eval:ret_expr/3 2 0.00 0 [ 0.00]
erl_eval:eval_fun/2 1 0.00 0 [ 0.00]
erl_eval:expr_list/4 1 0.00 0 [ 0.00]
erl_eval:guard/4 1 0.00 0 [ 0.00]
erl_eval:guard0/4 1 0.00 0 [ 0.00]
erl_eval:match_list/4 1 0.00 0 [ 0.00]