Skip to content

Commit 324187b

Browse files
committed
List.zip/1 vs Enum.zip/1
1 parent bb0b173 commit 324187b

File tree

2 files changed

+105
-0
lines changed

2 files changed

+105
-0
lines changed

bench/list_zip.exs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
inputs =
2+
for length <- [10, 100], count <- [10, 100] do
3+
{"#{count} * #{length}", Enum.chunk_every(1..(length * count), length)}
4+
end
5+
6+
Benchee.run(
7+
%{
8+
"List.zip/1" => &List.zip/1,
9+
"Enum.zip/1" => &Enum.zip/1
10+
},
11+
memory_time: 0.5,
12+
inputs: inputs
13+
)

bench/list_zip.results.txt

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
Operating System: macOS
2+
CPU Information: Apple M1
3+
Number of Available Cores: 8
4+
Available memory: 16 GB
5+
Elixir 1.17.2
6+
Erlang 27.0
7+
8+
Benchmark suite executing with the following configuration:
9+
warmup: 2 s
10+
time: 5 s
11+
memory time: 500 ms
12+
reduction time: 0 ns
13+
parallel: 1
14+
inputs: 10 * 10, 100 * 10, 10 * 100, 100 * 100
15+
Estimated total run time: 1 min
16+
17+
Benchmarking Enum.zip/1 with input 10 * 10 ...
18+
Benchmarking Enum.zip/1 with input 100 * 10 ...
19+
Benchmarking Enum.zip/1 with input 10 * 100 ...
20+
Benchmarking Enum.zip/1 with input 100 * 100 ...
21+
Benchmarking List.zip/1 with input 10 * 10 ...
22+
Benchmarking List.zip/1 with input 100 * 10 ...
23+
Benchmarking List.zip/1 with input 10 * 100 ...
24+
Benchmarking List.zip/1 with input 100 * 100 ...
25+
26+
##### With input 10 * 10 #####
27+
Name ips average deviation median 99th %
28+
Enum.zip/1 1.06 M 0.94 μs ±4171.12% 0.75 μs 1.88 μs
29+
List.zip/1 0.69 M 1.45 μs ±1971.96% 1.29 μs 2.58 μs
30+
31+
Comparison:
32+
Enum.zip/1 1.06 M
33+
List.zip/1 0.69 M - 1.54x slower +0.51 μs
34+
35+
Memory usage statistics:
36+
37+
Name Memory usage
38+
Enum.zip/1 8.01 KB
39+
List.zip/1 10.98 KB - 1.37x memory usage +2.98 KB
40+
41+
**All measurements for memory usage were the same**
42+
43+
##### With input 100 * 10 #####
44+
Name ips average deviation median 99th %
45+
Enum.zip/1 120.91 K 8.27 μs ±175.70% 7.63 μs 16.88 μs
46+
List.zip/1 59.51 K 16.80 μs ±24.36% 16.33 μs 23.50 μs
47+
48+
Comparison:
49+
Enum.zip/1 120.91 K
50+
List.zip/1 59.51 K - 2.03x slower +8.53 μs
51+
52+
Memory usage statistics:
53+
54+
Name Memory usage
55+
Enum.zip/1 69.57 KB
56+
List.zip/1 105.43 KB - 1.52x memory usage +35.86 KB
57+
58+
**All measurements for memory usage were the same**
59+
60+
##### With input 10 * 100 #####
61+
Name ips average deviation median 99th %
62+
Enum.zip/1 120.19 K 8.32 μs ±360.77% 7.13 μs 26.71 μs
63+
List.zip/1 80.48 K 12.43 μs ±14.65% 12.13 μs 14.75 μs
64+
65+
Comparison:
66+
Enum.zip/1 120.19 K
67+
List.zip/1 80.48 K - 1.49x slower +4.10 μs
68+
69+
Memory usage statistics:
70+
71+
Name Memory usage
72+
Enum.zip/1 79.02 KB
73+
List.zip/1 108.14 KB - 1.37x memory usage +29.12 KB
74+
75+
**All measurements for memory usage were the same**
76+
77+
##### With input 100 * 100 #####
78+
Name ips average deviation median 99th %
79+
Enum.zip/1 12.77 K 78.31 μs ±20.22% 76.88 μs 110.38 μs
80+
List.zip/1 6.05 K 165.21 μs ±20.30% 161.38 μs 325.14 μs
81+
82+
Comparison:
83+
Enum.zip/1 12.77 K
84+
List.zip/1 6.05 K - 2.11x slower +86.90 μs
85+
86+
Memory usage statistics:
87+
88+
Name Memory usage
89+
Enum.zip/1 703.09 KB
90+
List.zip/1 1021.02 KB - 1.45x memory usage +317.93 KB
91+
92+
**All measurements for memory usage were the same**

0 commit comments

Comments
 (0)