summaryrefslogtreecommitdiffstats
path: root/benches
diff options
context:
space:
mode:
authorMatan Kushner <hello@matchai.me>2019-04-04 16:59:03 -0400
committerMatan Kushner <hello@matchai.me>2019-04-04 16:59:03 -0400
commit52a529c62736d5186453f095b15b0ce038ec72a7 (patch)
tree7562f39cbb330a2056a4a0eddad82f2168fe3f16 /benches
parent7136059dcd4d3b3fe6857dcf0542bd850a50d813 (diff)
Add basic benchmarks
Diffstat (limited to 'benches')
-rw-r--r--benches/benchmarks.rs45
1 files changed, 45 insertions, 0 deletions
diff --git a/benches/benchmarks.rs b/benches/benchmarks.rs
new file mode 100644
index 000000000..42a763b11
--- /dev/null
+++ b/benches/benchmarks.rs
@@ -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)
+ });
+ }
+}