summaryrefslogtreecommitdiffstats
path: root/library/core/benches/tuple.rs
blob: d9ff9d0dd9378feb4a21f5994e467e28c22a984f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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]
    });
}