summaryrefslogtreecommitdiffstats
path: root/vendor/ucd-trie/benches/bench.rs
blob: 53c04b9d0b7ca65622279f97efa066a3f8c3b9a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#![feature(test)]

#[macro_use]
extern crate lazy_static;
extern crate test;

use ucd_trie::TrieSetOwned;

#[bench]
fn bench_trie_set(b: &mut test::Bencher) {
    const CHARS: &'static [char] = &['a', 'β', '☃', '😼'];
    // const CHARS: &'static [char] = &['a'];
    lazy_static! {
        static ref SET: TrieSetOwned =
            TrieSetOwned::from_scalars(CHARS).unwrap();
    }

    let set = &*SET;
    let mut i = 0;
    b.iter(|| {
        let c = CHARS[i];
        i = (i + 1) % CHARS.len();

        for _ in 0..10000 {
            assert!(set.contains_char(c));
        }
    });
}