fn $FOR_WINDOWS(c: &mut Criterion) { let v: Vec<u32> = (0..1_000).collect(); letmut s = 0;
c.bench_function(&stringify!($FOR_WINDOWS).replace('_', " "), move |b| {
b.iter(|| { for i in0..(1_000 - $N) {
s += $SLICE_FUN(&v[i..(i + $N)]);
}
s
})
});
}
fn $TUPLES(c: &mut Criterion) { let v: Vec<u32> = (0.. $N * 1_000).collect(); letmut s = 0;
c.bench_function(&stringify!($TUPLES).replace('_', " "), move |b| {
b.iter(|| { for x in v.iter().tuples() {
s += $TUPLE_FUN(&x);
}
s
})
});
}
fn $CHUNKS(c: &mut Criterion) { let v: Vec<u32> = (0.. $N * 1_000).collect(); letmut s = 0;
c.bench_function(&stringify!($CHUNKS).replace('_', " "), move |b| {
b.iter(|| { for x in v.chunks($N) {
s += $SLICE_FUN(x);
}
s
})
});
}
fn $TUPLE_WINDOWS(c: &mut Criterion) { let v: Vec<u32> = (0..1_000).collect(); letmut s = 0;
c.bench_function(&stringify!($TUPLE_WINDOWS).replace('_', " "), move |b| {
b.iter(|| { for x in v.iter().tuple_windows() {
s += $TUPLE_FUN(&x);
}
s
})
});
}
fn $WINDOWS(c: &mut Criterion) { let v: Vec<u32> = (0..1_000).collect(); letmut s = 0;
c.bench_function(&stringify!($WINDOWS).replace('_', " "), move |b| {
b.iter(|| { for x in v.windows($N) {
s += $SLICE_FUN(x);
}
s
})
});
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.