diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:02:58 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:02:58 +0000 |
commit | 698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch) | |
tree | 173a775858bd501c378080a10dca74132f05bc50 /vendor/array_tool/benches | |
parent | Initial commit. (diff) | |
download | rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip |
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/array_tool/benches')
-rw-r--r-- | vendor/array_tool/benches/bench.rs | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/vendor/array_tool/benches/bench.rs b/vendor/array_tool/benches/bench.rs new file mode 100644 index 000000000..81e84de94 --- /dev/null +++ b/vendor/array_tool/benches/bench.rs @@ -0,0 +1,44 @@ +#![feature(test)] + +// NOTES +// +// string slices are faster than character iteration with method nth. + +extern crate test; +use test::Bencher; +extern crate array_tool; +use array_tool::*; + +#[bench] +fn uniques1(b: &mut Bencher){ + b.iter(|| { + let a: Vec<i32> = vec![1,43,6,26,62,7,27,2,3,62,246,2346,6,7,2,35,62,6,325,56,63,25,4,8,8727,7,74,452]; + let d: Vec<i32> = vec![36,63,74,872,2,772,7,2,54,265,3245,45,754,235,4567,67,23,2,542,352]; + uniques(a, d) + }) +} + +#[bench] +fn times(b: &mut Bencher){ + b.iter(|| { + use array_tool::vec::Times; + vec![1,2,3,4,5,6].times(150); + }); +} + +#[bench] +fn subst_marks(b: &mut Bencher){ + b.iter(|| { + use array_tool::string::SubstMarks; + "dfgklerfgseawrfgawergq35g4w6uw4372472q4762q47yq35uw4567u32qy7q3yuq3".subst_marks( + vec![0,3,6,9,12,24,34,40], "Z"); + }); +} + +#[bench] +fn word_wrap(b: &mut Bencher){ + b.iter(|| { + use array_tool::string::WordWrap; + "asdf sdf s df d sd\n sf sfg sg g\n sfdgsg\n gfdga a\n ".word_wrap(3); + }); +} |