-
Notifications
You must be signed in to change notification settings - Fork 58
/
Copy pathbenchmark.rs
60 lines (53 loc) · 1.5 KB
/
benchmark.rs
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
52
53
54
55
56
57
58
59
60
#![feature(test)]
extern crate test;
#[cfg(test)]
mod bench {
use std::env;
use std::process::Command;
use test::Bencher;
#[bench]
fn no_translation(b: &mut Bencher) {
b.iter(|| {
Command::new("wslgit")
.args(&["--version"])
.env("WSLGIT_USE_INTERACTIVE_SHELL", "false")
.output()
})
}
#[bench]
fn translate_absolute_argument(b: &mut Bencher) {
let p = env::current_dir()
.unwrap()
.as_path()
.join("src\\main.rs")
.as_path()
.to_string_lossy()
.into_owned();
let file_path = p.as_str();
b.iter(|| {
Command::new("wslgit")
.args(&["log", "-n1", "--oneline", "--", file_path])
.env("WSLGIT_USE_INTERACTIVE_SHELL", "false")
.output()
})
}
#[bench]
fn translate_relative_argument(b: &mut Bencher) {
let file_path = "src\\main.rs";
b.iter(|| {
Command::new("wslgit")
.args(&["log", "-n1", "--oneline", "--", file_path])
.env("WSLGIT_USE_INTERACTIVE_SHELL", "false")
.output()
})
}
#[bench]
fn translate_output(b: &mut Bencher) {
b.iter(|| {
Command::new("wslgit")
.args(&["rev-parse", "--show-toplevel"])
.env("WSLGIT_USE_INTERACTIVE_SHELL", "false")
.output()
})
}
}