-
Notifications
You must be signed in to change notification settings - Fork 66
/
multiple_inputs.exs
62 lines (52 loc) · 2.1 KB
/
multiple_inputs.exs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
map_fun = fn i -> [i, i * i] end
Benchee.run(
%{
"flat_map" => fn input -> Enum.flat_map(input, map_fun) end,
"map.flatten" => fn input -> input |> Enum.map(map_fun) |> List.flatten() end
},
inputs: %{
"Small" => Enum.to_list(1..1_000),
"Medium" => Enum.to_list(1..10_000),
"Bigger" => Enum.to_list(1..100_000)
}
)
# Operating System: Linux
# CPU Information: Intel(R) Core(TM) i7-4790 CPU @ 3.60GHz
# Number of Available Cores: 8
# Available memory: 15.61 GB
# Elixir 1.8.1
# Erlang 21.3.2
# Benchmark suite executing with the following configuration:
# warmup: 2 s
# time: 5 s
# memory time: 0 ns
# parallel: 1
# inputs: Bigger, Medium, Small
# Estimated total run time: 42 s
# Benchmarking flat_map with input Bigger...
# Benchmarking flat_map with input Medium...
# Benchmarking flat_map with input Small...
# Benchmarking map.flatten with input Bigger...
# Benchmarking map.flatten with input Medium...
# Benchmarking map.flatten with input Small...
# ##### With input Bigger #####
# Name ips average deviation median 99th %
# flat_map 148.45 6.74 ms ±16.22% 6.47 ms 10.14 ms
# map.flatten 111.47 8.97 ms ±19.02% 8.61 ms 14.02 ms
# Comparison:
# flat_map 148.45
# map.flatten 111.47 - 1.33x slower +2.23 ms
# ##### With input Medium #####
# Name ips average deviation median 99th %
# flat_map 2.34 K 426.50 μs ±17.11% 405.51 μs 817.00 μs
# map.flatten 1.79 K 558.80 μs ±19.87% 523.28 μs 1064.58 μs
# Comparison:
# flat_map 2.34 K
# map.flatten 1.79 K - 1.31x slower +132.31 μs
# ##### With input Small #####
# Name ips average deviation median 99th %
# flat_map 24.42 K 40.95 μs ±31.34% 34.88 μs 77.32 μs
# map.flatten 18.06 K 55.36 μs ±26.46% 49.52 μs 105.45 μs
# Comparison:
# flat_map 24.42 K
# map.flatten 18.06 K - 1.35x slower +14.41 μs