Skip to content

Commit 5b9d684

Browse files
author
root
committed
Fix inconsistensies in benchmarks. New results!
The ZipTrusted is just as fast as the unchecked loop for both n=2 and n=3 this way! test zip_loop ... bench: 589 ns/iter (+/- 4) test zip_loop3 ... bench: 862 ns/iter (+/- 75) test zip_slices_default_zip ... bench: 626 ns/iter (+/- 9) test zip_slices_default_zip3 ... bench: 1155 ns/iter (+/- 14) test ziptrusted ... bench: 590 ns/iter (+/- 74) test ziptrusted3 ... bench: 865 ns/iter (+/- 81)
1 parent 7bf94f9 commit 5b9d684

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

benches/bench1.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ fn zip_slices_default_zip(b: &mut test::Bencher)
106106
let xs = vec![0; 1024];
107107
let ys = vec![0; 768];
108108

109-
b.iter(|| for (x, y) in xs.iter().zip(ys.iter()) {
109+
b.iter(|| for (&x, &y) in xs.iter().zip(ys.iter()) {
110110
test::black_box(x);
111111
test::black_box(y);
112112
})
@@ -119,7 +119,7 @@ fn zip_slices_default_zip3(b: &mut test::Bencher)
119119
let ys = vec![0; 768];
120120
let zs = vec![0; 766];
121121

122-
b.iter(|| for ((x, y), z) in xs.iter().zip(ys.iter()).zip(zs.iter()) {
122+
b.iter(|| for ((&x, &y), &z) in xs.iter().zip(ys.iter()).zip(zs.iter()) {
123123
test::black_box(x);
124124
test::black_box(y);
125125
test::black_box(z);
@@ -132,7 +132,7 @@ fn zip_slices_ziptuple(b: &mut test::Bencher)
132132
let xs = vec![0; 1024];
133133
let ys = vec![0; 768];
134134

135-
b.iter(|| for (x, y) in Zip::new((xs.iter(), ys.iter())) {
135+
b.iter(|| for (&x, &y) in Zip::new((xs.iter(), ys.iter())) {
136136
test::black_box(x);
137137
test::black_box(y);
138138
})
@@ -144,7 +144,7 @@ fn zipslices(b: &mut test::Bencher)
144144
let xs = vec![0; 1024];
145145
let ys = vec![0; 768];
146146

147-
b.iter(|| for (x, y) in ZipSlices::new(&xs, &ys) {
147+
b.iter(|| for (&x, &y) in ZipSlices::new(&xs, &ys) {
148148
test::black_box(x);
149149
test::black_box(y);
150150
})
@@ -156,7 +156,7 @@ fn ziptrusted(b: &mut test::Bencher)
156156
let xs = vec![0; 1024];
157157
let ys = vec![0; 768];
158158

159-
b.iter(|| for (x, y) in ZipTrusted::new((xs.iter(), ys.iter())) {
159+
b.iter(|| for (&x, &y) in ZipTrusted::new((xs.iter(), ys.iter())) {
160160
test::black_box(x);
161161
test::black_box(y);
162162
})
@@ -169,7 +169,7 @@ fn ziptrusted3(b: &mut test::Bencher)
169169
let ys = vec![0; 768];
170170
let zs = vec![0; 766];
171171

172-
b.iter(|| for (x, y, z) in ZipTrusted::new((xs.iter(), ys.iter(), zs.iter())) {
172+
b.iter(|| for (&x, &y, &z) in ZipTrusted::new((xs.iter(), ys.iter(), zs.iter())) {
173173
test::black_box(x);
174174
test::black_box(y);
175175
test::black_box(z);
@@ -208,7 +208,7 @@ fn zip_loop3(b: &mut test::Bencher)
208208
unsafe {
209209
let x = *xs.get_unchecked(i);
210210
let y = *ys.get_unchecked(i);
211-
let z = *ys.get_unchecked(i);
211+
let z = *zs.get_unchecked(i);
212212
test::black_box(x);
213213
test::black_box(y);
214214
test::black_box(z);

0 commit comments

Comments
 (0)