1
0
mirror of https://github.com/Llewellynvdm/starship.git synced 2024-12-01 01:04:00 +00:00

Add basic benchmarks

This commit is contained in:
Matan Kushner 2019-04-04 16:59:03 -04:00
parent 7136059dcd
commit 52a529c627
No known key found for this signature in database
GPG Key ID: 4B98C3A8949CA8A4
5 changed files with 50 additions and 2 deletions

2
Cargo.lock generated
View File

@ -1,3 +1,5 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]] [[package]]
name = "ansi_term" name = "ansi_term"
version = "0.11.0" version = "0.11.0"

45
benches/benchmarks.rs Normal file
View File

@ -0,0 +1,45 @@
#![feature(test)]
extern crate test;
#[cfg(test)]
mod tests {
use starship::{modules, print};
use test::Bencher;
use clap::{App, Arg};
#[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)
});
}
#[bench]
fn char_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("char", &args);
print::print_segment(segment)
});
}
#[bench]
fn dir_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("dir", &args);
print::print_segment(segment)
});
}
}

2
src/lib.rs Normal file
View File

@ -0,0 +1,2 @@
pub mod modules;
pub mod print;

View File

@ -1,6 +1,5 @@
#[macro_use] #[macro_use]
extern crate clap; extern crate clap;
extern crate ansi_term;
mod modules; mod modules;
mod print; mod print;

View File

@ -11,7 +11,7 @@ pub fn prompt(args: ArgMatches) {
} }
} }
fn print_segment(segment: Segment) { pub fn print_segment(segment: Segment) {
let Segment { let Segment {
prefix, prefix,
value, value,