summaryrefslogtreecommitdiffstats
path: root/library/core/benches
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:39 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:39 +0000
commit1376c5a617be5c25655d0d7cb63e3beaa5a6e026 (patch)
tree3bb8d61aee02bc7a15eab3f36e3b921afc2075d0 /library/core/benches
parentReleasing progress-linux version 1.69.0+dfsg1-1~progress7.99u1. (diff)
downloadrustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.tar.xz
rustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.zip
Merging upstream version 1.70.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'library/core/benches')
-rw-r--r--library/core/benches/lib.rs1
-rw-r--r--library/core/benches/tuple.rs22
2 files changed, 23 insertions, 0 deletions
diff --git a/library/core/benches/lib.rs b/library/core/benches/lib.rs
index e4100120d..74ef0949b 100644
--- a/library/core/benches/lib.rs
+++ b/library/core/benches/lib.rs
@@ -20,6 +20,7 @@ mod ops;
mod pattern;
mod slice;
mod str;
+mod tuple;
/// Returns a `rand::Rng` seeded with a consistent seed.
///
diff --git a/library/core/benches/tuple.rs b/library/core/benches/tuple.rs
new file mode 100644
index 000000000..d9ff9d0dd
--- /dev/null
+++ b/library/core/benches/tuple.rs
@@ -0,0 +1,22 @@
+use rand::prelude::*;
+use test::{black_box, Bencher};
+
+#[bench]
+fn bench_tuple_comparison(b: &mut Bencher) {
+ let mut rng = black_box(super::bench_rng());
+
+ let data = black_box([
+ ("core::iter::adapters::Chain", 123_usize),
+ ("core::iter::adapters::Clone", 456_usize),
+ ("core::iter::adapters::Copie", 789_usize),
+ ("core::iter::adapters::Cycle", 123_usize),
+ ("core::iter::adapters::Flatt", 456_usize),
+ ("core::iter::adapters::TakeN", 789_usize),
+ ]);
+
+ b.iter(|| {
+ let x = data.choose(&mut rng).unwrap();
+ let y = data.choose(&mut rng).unwrap();
+ [x < y, x <= y, x > y, x >= y]
+ });
+}