diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
commit | 2aa4a82499d4becd2284cdb482213d541b8804dd (patch) | |
tree | b80bf8bf13c3766139fbacc530efd0dd9d54394c /third_party/rust/constant_time_eq/benches | |
parent | Initial commit. (diff) | |
download | firefox-upstream.tar.xz firefox-upstream.zip |
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/constant_time_eq/benches')
-rw-r--r-- | third_party/rust/constant_time_eq/benches/bench.rs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/third_party/rust/constant_time_eq/benches/bench.rs b/third_party/rust/constant_time_eq/benches/bench.rs new file mode 100644 index 0000000000..4b3b790a5d --- /dev/null +++ b/third_party/rust/constant_time_eq/benches/bench.rs @@ -0,0 +1,29 @@ +#![feature(test)] + +extern crate constant_time_eq; +extern crate test; + +use constant_time_eq::constant_time_eq; +use test::{Bencher, black_box}; + +fn bench(b: &mut Bencher, left: &[u8], right: &[u8]) { + b.bytes = (left.len() + right.len()) as u64; + b.iter(|| { + constant_time_eq(black_box(left), black_box(right)) + }) +} + +#[bench] +fn bench_16(b: &mut Bencher) { + bench(b, &[0; 16], &[0; 16]) +} + +#[bench] +fn bench_4096(b: &mut Bencher) { + bench(b, &[0; 4096], &[0; 4096]) +} + +#[bench] +fn bench_65536(b: &mut Bencher) { + bench(b, &[0; 65536], &[0; 65536]) +} |