Created
April 3, 2017 11:57
-
-
Save x4lldux/173c59a1d838d65c1028d935bf71f75b to your computer and use it in GitHub Desktop.
benchmarking map serializoation
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
defmodule Benchit do | |
def run do | |
ml = for i<- 1..1_000_000, do: {i,[]}, into: %{} | |
mt = for i<- 1..1_000_000, do: {i,true}, into: %{} | |
bl = :erlang.term_to_binary ml | |
bt = :erlang.term_to_binary mt | |
Benchee.run %{ | |
"serialize empty list" => fn -> :erlang.term_to_binary ml end, | |
"serialize true" => fn -> :erlang.term_to_binary mt end, | |
"deserialize empty list" => fn -> :erlang.binary_to_term bl end, | |
"deserialize true" => fn -> :erlang.binary_to_term bt end, | |
}, time: 10, parallel: 4 | |
end | |
end |
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_ENV=prod mix run -e 'Benchit.run' | |
Erlang/OTP 19 [erts-8.2.1] [source] [64-bit] [smp:28:28] [async-threads:10] [hipe] [kernel-poll:false] | |
Elixir 1.4.2 | |
Benchmark suite executing with the following configuration: | |
warmup: 2.0s | |
time: 10.0s | |
parallel: 4 | |
inputs: none specified | |
Estimated total run time: 48.0s | |
Benchmarking deserialize empty list... | |
Benchmarking deserialize true... | |
Benchmarking serialize empty list... | |
Benchmarking serialize true... | |
Name ips average deviation median | |
serialize empty list 22.53 44.38 ms ±3.77% 44.15 ms | |
serialize true 18.35 54.51 ms ±3.05% 54.46 ms | |
deserialize empty list 6.07 164.77 ms ±7.63% 158.50 ms | |
deserialize true 4.14 241.48 ms ±4.71% 235.95 ms | |
Comparison: | |
serialize empty list 22.53 | |
serialize true 18.35 - 1.23x slower | |
deserialize empty list 6.07 - 3.71x slower | |
deserialize true 4.14 - 5.44x slower |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
tested on:
Intel(R) Xeon(R) CPU E5-2695 v3 @ 2.30GHz