File: bench.rs

package info (click to toggle)
rust-path-dedot 3.1.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 136 kB
  • sloc: makefile: 2
file content (51 lines) | stat: -rw-r--r-- 1,131 bytes parent folder | download
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
use std::path::Path;

use bencher::{benchmark_group, benchmark_main, Bencher};
use path_dedot::ParseDot;

fn no_dots(bencher: &mut Bencher) {
    #[cfg(feature = "unsafe_cache")]
    unsafe {
        path_dedot::update_cwd()
    };

    let path = Path::new("path/to/123/456");

    bencher.iter(|| path.parse_dot());
}

fn starts_with_a_single_dot(bencher: &mut Bencher) {
    #[cfg(feature = "unsafe_cache")]
    unsafe {
        path_dedot::update_cwd()
    };

    let path = Path::new("./path/to/123/456");

    bencher.iter(|| path.parse_dot());
}

fn starts_with_double_dots(bencher: &mut Bencher) {
    #[cfg(feature = "unsafe_cache")]
    unsafe {
        path_dedot::update_cwd()
    };

    let path = Path::new("../path/to/123/456");

    bencher.iter(|| path.parse_dot());
}

fn mix(bencher: &mut Bencher) {
    #[cfg(feature = "unsafe_cache")]
    unsafe {
        path_dedot::update_cwd()
    };

    let path = Path::new("./path/to/123/../456");

    bencher.iter(|| path.parse_dot());
}

benchmark_group!(bench_group, no_dots, starts_with_a_single_dot, starts_with_double_dots, mix);
benchmark_main!(bench_group);