mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 21:01:08 +00:00
b28df3b531
This has the side effect of adding another version of uuid, which we'll upgrade for other dependencies subsequently. Differential Revision: https://phabricator.services.mozilla.com/D55911 --HG-- rename : third_party/rust/uuid/.cargo-checksum.json => third_party/rust/uuid-0.7.4/.cargo-checksum.json rename : third_party/rust/uuid/Cargo.toml => third_party/rust/uuid-0.7.4/Cargo.toml rename : third_party/rust/uuid/README.md => third_party/rust/uuid-0.7.4/README.md rename : third_party/rust/uuid/README.tpl => third_party/rust/uuid-0.7.4/README.tpl rename : third_party/rust/uuid/benches/format_str.rs => third_party/rust/uuid-0.7.4/benches/format_str.rs rename : third_party/rust/uuid/benches/invalid_parse_str.rs => third_party/rust/uuid-0.7.4/benches/invalid_parse_str.rs rename : third_party/rust/uuid/benches/mod.rs => third_party/rust/uuid-0.7.4/benches/mod.rs rename : third_party/rust/uuid/benches/serde_support.rs => third_party/rust/uuid-0.7.4/benches/serde_support.rs rename : third_party/rust/uuid/benches/slog_support/mod.rs => third_party/rust/uuid-0.7.4/benches/slog_support/mod.rs rename : third_party/rust/uuid/benches/slog_support/parse_str.rs => third_party/rust/uuid-0.7.4/benches/slog_support/parse_str.rs rename : third_party/rust/uuid/benches/valid_parse_str.rs => third_party/rust/uuid-0.7.4/benches/valid_parse_str.rs rename : third_party/rust/uuid/src/adapter/compact.rs => third_party/rust/uuid-0.7.4/src/adapter/compact.rs rename : third_party/rust/uuid/src/adapter/core_support/mod.rs => third_party/rust/uuid-0.7.4/src/adapter/core_support/mod.rs rename : third_party/rust/uuid/src/adapter/mod.rs => third_party/rust/uuid-0.7.4/src/adapter/mod.rs rename : third_party/rust/uuid/src/builder.rs => third_party/rust/uuid-0.7.4/src/builder.rs rename : third_party/rust/uuid/src/core_support.rs => third_party/rust/uuid-0.7.4/src/core_support.rs rename : third_party/rust/uuid/src/lib.rs => third_party/rust/uuid-0.7.4/src/lib.rs rename : third_party/rust/uuid/src/parser/core_support.rs => third_party/rust/uuid-0.7.4/src/parser/core_support.rs rename : third_party/rust/uuid/src/parser/mod.rs => third_party/rust/uuid-0.7.4/src/parser/mod.rs rename : third_party/rust/uuid/src/parser/std_support.rs => third_party/rust/uuid-0.7.4/src/parser/std_support.rs rename : third_party/rust/uuid/src/prelude.rs => third_party/rust/uuid-0.7.4/src/prelude.rs rename : third_party/rust/uuid/src/serde_support.rs => third_party/rust/uuid-0.7.4/src/serde_support.rs rename : third_party/rust/uuid/src/slog_support.rs => third_party/rust/uuid-0.7.4/src/slog_support.rs rename : third_party/rust/uuid/src/std_support.rs => third_party/rust/uuid-0.7.4/src/std_support.rs rename : third_party/rust/uuid/src/test_util.rs => third_party/rust/uuid-0.7.4/src/test_util.rs rename : third_party/rust/uuid/src/u128_support.rs => third_party/rust/uuid-0.7.4/src/u128_support.rs rename : third_party/rust/uuid/src/v1.rs => third_party/rust/uuid-0.7.4/src/v1.rs rename : third_party/rust/uuid/src/v3.rs => third_party/rust/uuid-0.7.4/src/v3.rs rename : third_party/rust/uuid/src/v4.rs => third_party/rust/uuid-0.7.4/src/v4.rs rename : third_party/rust/uuid/src/v5.rs => third_party/rust/uuid-0.7.4/src/v5.rs rename : third_party/rust/uuid/src/winapi_support.rs => third_party/rust/uuid-0.7.4/src/winapi_support.rs extra : moz-landing-system : lando
158 lines
3.9 KiB
Rust
158 lines
3.9 KiB
Rust
#![feature(test)]
|
|
extern crate test;
|
|
|
|
use scroll::{Cread, Pread, LE};
|
|
use test::black_box;
|
|
|
|
#[bench]
|
|
fn bench_parallel_cread_with(b: &mut test::Bencher) {
|
|
use rayon::prelude::*;
|
|
let vec = vec![0u8; 1_000_000];
|
|
let nums = vec![0usize; 500_000];
|
|
b.iter(|| {
|
|
let data = black_box(&vec[..]);
|
|
nums.par_iter().for_each(| offset | {
|
|
let _: u16 = black_box(data.cread_with(*offset, LE));
|
|
});
|
|
});
|
|
b.bytes = vec.len() as u64;
|
|
}
|
|
|
|
#[bench]
|
|
fn bench_cread_vec(b: &mut test::Bencher) {
|
|
let vec = vec![0u8; 1_000_000];
|
|
b.iter(|| {
|
|
let data = black_box(&vec[..]);
|
|
for val in data.chunks(2) {
|
|
let _: u16 = black_box(val.cread_with(0, LE));
|
|
}
|
|
});
|
|
b.bytes = vec.len() as u64;
|
|
}
|
|
|
|
#[bench]
|
|
fn bench_cread(b: &mut test::Bencher) {
|
|
const NITER: i32 = 100_000;
|
|
b.iter(|| {
|
|
for _ in 1..NITER {
|
|
let data = black_box([1, 2]);
|
|
let _: u16 = black_box(data.cread(0));
|
|
}
|
|
});
|
|
b.bytes = 2 * NITER as u64;
|
|
}
|
|
|
|
#[bench]
|
|
fn bench_pread_ctx_vec(b: &mut test::Bencher) {
|
|
let vec = vec![0u8; 1_000_000];
|
|
b.iter(|| {
|
|
let data = black_box(&vec[..]);
|
|
for val in data.chunks(2) {
|
|
let _: Result<u16, _> = black_box(val.pread(0));
|
|
}
|
|
});
|
|
b.bytes = vec.len() as u64;
|
|
}
|
|
|
|
#[bench]
|
|
fn bench_pread_with_unwrap(b: &mut test::Bencher) {
|
|
const NITER: i32 = 100_000;
|
|
b.iter(|| {
|
|
for _ in 1..NITER {
|
|
let data: &[u8] = &black_box([1, 2]);
|
|
let _: u16 = black_box(data.pread_with(0, LE).unwrap());
|
|
}
|
|
});
|
|
b.bytes = 2 * NITER as u64;
|
|
}
|
|
|
|
#[bench]
|
|
fn bench_pread_vec(b: &mut test::Bencher) {
|
|
let vec = vec![0u8; 1_000_000];
|
|
b.iter(|| {
|
|
let data = black_box(&vec[..]);
|
|
for val in data.chunks(2) {
|
|
let _: Result<u16, _> = black_box(val.pread_with(0, LE));
|
|
}
|
|
});
|
|
b.bytes = vec.len() as u64;
|
|
}
|
|
|
|
#[bench]
|
|
fn bench_pread_unwrap(b: &mut test::Bencher) {
|
|
const NITER: i32 = 100_000;
|
|
b.iter(|| {
|
|
for _ in 1..NITER {
|
|
let data = black_box([1, 2]);
|
|
let _: u16 = black_box(data.pread(0)).unwrap();
|
|
}
|
|
});
|
|
b.bytes = 2 * NITER as u64;
|
|
}
|
|
|
|
#[bench]
|
|
fn bench_gread_vec(b: &mut test::Bencher) {
|
|
let vec = vec![0u8; 1_000_000];
|
|
b.iter(|| {
|
|
let data = black_box(&vec[..]);
|
|
for val in data.chunks(2) {
|
|
let mut offset = 0;
|
|
let _: Result<u16, _> = black_box(val.gread(&mut offset));
|
|
}
|
|
});
|
|
b.bytes = vec.len() as u64;
|
|
}
|
|
|
|
#[bench]
|
|
fn bench_gread_unwrap(b: &mut test::Bencher) {
|
|
const NITER: i32 = 100_000;
|
|
b.iter(|| {
|
|
for _ in 1..NITER {
|
|
let data = black_box([1, 2]);
|
|
let mut offset = 0;
|
|
let _: u16 = black_box(data.gread_with(&mut offset, LE).unwrap());
|
|
}
|
|
});
|
|
b.bytes = 2 * NITER as u64;
|
|
}
|
|
|
|
#[bench]
|
|
fn bench_parallel_pread_with(b: &mut test::Bencher) {
|
|
use rayon::prelude::*;
|
|
let vec = vec![0u8; 1_000_000];
|
|
let nums = vec![0usize; 500_000];
|
|
b.iter(|| {
|
|
let data = black_box(&vec[..]);
|
|
nums.par_iter().for_each(| offset | {
|
|
let _: Result<u16, _> = black_box(data.pread_with(*offset, LE));
|
|
});
|
|
});
|
|
b.bytes = vec.len() as u64;
|
|
}
|
|
|
|
#[bench]
|
|
fn bench_byteorder_vec(b: &mut test::Bencher) {
|
|
use byteorder::ReadBytesExt;
|
|
let vec = vec![0u8; 1_000_000];
|
|
b.iter(|| {
|
|
let data = black_box(&vec[..]);
|
|
for mut val in data.chunks(2) {
|
|
let _: Result<u16, _> = black_box(val.read_u16::<byteorder::LittleEndian>());
|
|
}
|
|
});
|
|
b.bytes = vec.len() as u64;
|
|
}
|
|
|
|
#[bench]
|
|
fn bench_byteorder(b: &mut test::Bencher) {
|
|
use byteorder::ByteOrder;
|
|
const NITER: i32 = 100_000;
|
|
b.iter(|| {
|
|
for _ in 1..NITER {
|
|
let data = black_box([1, 2]);
|
|
let _: u16 = black_box(byteorder::LittleEndian::read_u16(&data));
|
|
}
|
|
});
|
|
b.bytes = 2 * NITER as u64;
|
|
}
|