diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /third_party/rust/line-wrap/benches | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/line-wrap/benches')
-rw-r--r-- | third_party/rust/line-wrap/benches/benchmarks.rs | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/third_party/rust/line-wrap/benches/benchmarks.rs b/third_party/rust/line-wrap/benches/benchmarks.rs new file mode 100644 index 0000000000..a8d84948dc --- /dev/null +++ b/third_party/rust/line-wrap/benches/benchmarks.rs @@ -0,0 +1,97 @@ +#![feature(test)] + +extern crate line_wrap; +extern crate test; + +use test::Bencher; + +#[bench] +fn wrap_10_10_lf(b: &mut Bencher) { + do_wrap_bench(b, 10, 10, &line_wrap::lf()); +} + +#[bench] +fn wrap_10_10_crlf(b: &mut Bencher) { + do_wrap_bench(b, 10, 10, &line_wrap::crlf()); +} + +#[bench] +fn wrap_10_1_lf(b: &mut Bencher) { + do_wrap_bench(b, 10, 1, &line_wrap::lf()); +} + +#[bench] +fn wrap_10_1_crlf(b: &mut Bencher) { + do_wrap_bench(b, 10, 1, &line_wrap::crlf()); +} + +#[bench] +fn wrap_100_10_lf(b: &mut Bencher) { + do_wrap_bench(b, 100, 10, &line_wrap::lf()); +} + +#[bench] +fn wrap_100_10_crlf(b: &mut Bencher) { + do_wrap_bench(b, 100, 10, &line_wrap::crlf()); +} + +#[bench] +fn wrap_100_10_slice_10(b: &mut Bencher) { + let bytes = vec![b'\n', 10]; + let line_ending = line_wrap::SliceLineEnding::new(&bytes); + do_wrap_bench(b, 100, 10, &line_ending); +} + +#[bench] +fn wrap_100_1_lf(b: &mut Bencher) { + do_wrap_bench(b, 100, 1, &line_wrap::lf()); +} + +#[bench] +fn wrap_100_1_crlf(b: &mut Bencher) { + do_wrap_bench(b, 100, 1, &line_wrap::crlf()); +} + +#[bench] +fn wrap_1000_100_lf(b: &mut Bencher) { + do_wrap_bench(b, 1000, 100, &line_wrap::lf()); +} + +#[bench] +fn wrap_1000_100_crlf(b: &mut Bencher) { + do_wrap_bench(b, 1000, 100, &line_wrap::crlf()); +} + +#[bench] +fn wrap_10000_100_lf(b: &mut Bencher) { + do_wrap_bench(b, 10000, 100, &line_wrap::lf()); +} + +#[bench] +fn wrap_10000_100_crlf(b: &mut Bencher) { + do_wrap_bench(b, 10000, 100, &line_wrap::crlf()); +} + +#[bench] +fn wrap_10000_100_slice_1(b: &mut Bencher) { + let line_ending = line_wrap::SliceLineEnding::new(b"\n"); + + do_wrap_bench(b, 10000, 100, &line_ending); +} + +#[bench] +fn wrap_10000_100_slice_10(b: &mut Bencher) { + let bytes = vec![b'\n', 10]; + let line_ending = line_wrap::SliceLineEnding::new(&bytes); + + do_wrap_bench(b, 10000, 100, &line_ending); +} + +fn do_wrap_bench<L: line_wrap::LineEnding>(b: &mut Bencher, input_len: usize, line_len: usize, line_ending: &L) { + let mut v = vec![0_u8; input_len + input_len / line_len * line_ending.len()]; + + b.bytes = input_len as u64; + b.iter(|| { + line_wrap::line_wrap(&mut v, input_len, line_len, line_ending); + }) +}
\ No newline at end of file |