2019-04-04 20:59:03 +00:00
|
|
|
#![feature(test)]
|
|
|
|
|
|
|
|
extern crate test;
|
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
mod tests {
|
2019-04-05 01:35:24 +00:00
|
|
|
use clap::{App, Arg};
|
2019-04-12 23:13:14 +00:00
|
|
|
use starship::modules;
|
2019-04-04 20:59:03 +00:00
|
|
|
use test::Bencher;
|
|
|
|
|
2019-04-12 17:17:05 +00:00
|
|
|
// #[bench]
|
|
|
|
// fn full_prompt_bench(b: &mut Bencher) {
|
|
|
|
// b.iter(|| {
|
|
|
|
// let args = App::new("starship")
|
|
|
|
// .arg(Arg::with_name("status_code"))
|
|
|
|
// .get_matches_from(vec!["starship", "0"]);
|
|
|
|
|
|
|
|
// starship::print::prompt(args)
|
|
|
|
// });
|
|
|
|
// }
|
|
|
|
|
2019-04-04 20:59:03 +00:00
|
|
|
#[bench]
|
2019-04-12 17:17:05 +00:00
|
|
|
fn char_section_bench(b: &mut Bencher) {
|
2019-04-05 01:35:24 +00:00
|
|
|
b.iter(|| {
|
2019-04-04 20:59:03 +00:00
|
|
|
let args = App::new("starship")
|
|
|
|
.arg(Arg::with_name("status_code"))
|
|
|
|
.get_matches_from(vec!["starship", "0"]);
|
|
|
|
|
2019-04-12 17:17:05 +00:00
|
|
|
let segment = modules::handle("char", &args);
|
2019-04-12 23:13:14 +00:00
|
|
|
segment.output()
|
2019-04-04 20:59:03 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
#[bench]
|
2019-04-12 17:17:05 +00:00
|
|
|
fn dir_section_bench(b: &mut Bencher) {
|
2019-04-04 20:59:03 +00:00
|
|
|
b.iter(|| {
|
|
|
|
let args = App::new("starship")
|
|
|
|
.arg(Arg::with_name("status_code"))
|
|
|
|
.get_matches_from(vec!["starship", "0"]);
|
2019-04-05 01:35:24 +00:00
|
|
|
|
2019-04-12 17:17:05 +00:00
|
|
|
let segment = modules::handle("dir", &args);
|
2019-04-12 23:13:14 +00:00
|
|
|
segment.output()
|
2019-04-12 17:07:41 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-04-12 17:10:31 +00:00
|
|
|
#[bench]
|
2019-04-12 17:17:05 +00:00
|
|
|
fn line_break_section_bench(b: &mut Bencher) {
|
2019-04-12 17:07:41 +00:00
|
|
|
b.iter(|| {
|
|
|
|
let args = App::new("starship")
|
|
|
|
.arg(Arg::with_name("status_code"))
|
|
|
|
.get_matches_from(vec!["starship", "0"]);
|
|
|
|
|
2019-04-12 17:17:05 +00:00
|
|
|
let segment = modules::handle("line_break", &args);
|
2019-04-12 23:13:14 +00:00
|
|
|
segment.output()
|
2019-04-12 17:17:05 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
#[bench]
|
|
|
|
fn nodejs_section_bench(b: &mut Bencher) {
|
|
|
|
b.iter(|| {
|
|
|
|
let args = App::new("starship")
|
|
|
|
.arg(Arg::with_name("status_code"))
|
|
|
|
.get_matches_from(vec!["starship", "0"]);
|
|
|
|
|
|
|
|
let segment = modules::handle("nodejs", &args);
|
2019-04-12 23:13:14 +00:00
|
|
|
segment.output()
|
2019-04-04 20:59:03 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|