aboutsummaryrefslogtreecommitdiff
path: root/benches/bench.rs
blob: 0e9f154b1725247d55ec350e4d7c9aa17edc775e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Copyright (C) 2021-2021 Fuwn
// SPDX-License-Identifier: GPL-3.0-only

#[macro_use]
extern crate criterion;

use criterion::Criterion;
use rand::Rng;

fn bench_generate(c: &mut Criterion) {
  c.bench_function("generate", |b| {
    b.iter(|| {
      rand::thread_rng()
        .sample_iter(rand::distributions::Alphanumeric)
        .take(16)
        .map(char::from)
        .collect::<String>()
    })
  });
}

criterion_group!(benches, bench_generate);
criterion_main!(benches);