summaryrefslogtreecommitdiffstats
path: root/benches
diff options
context:
space:
mode:
authorMatan Kushner <hello@matchai.me>2019-05-09 23:51:50 -0400
committerGitHub <noreply@github.com>2019-05-09 23:51:50 -0400
commit8b5055d5106da402f9a132f0ed21571ef98b8ac2 (patch)
treed5d83454742235f44b183b932355189983ba074c /benches
parentc6ee5c6ac16d360ab1a44d097c91fe9f98f20f85 (diff)
Parallelize prompt modules (#46)
Diffstat (limited to 'benches')
-rw-r--r--benches/my_benchmark.rs27
1 files changed, 26 insertions, 1 deletions
diff --git a/benches/my_benchmark.rs b/benches/my_benchmark.rs
index e16c8cab0..be6898bb3 100644
--- a/benches/my_benchmark.rs
+++ b/benches/my_benchmark.rs
@@ -6,6 +6,8 @@ use criterion::Criterion;
use clap::{App, Arg};
use starship::context::Context;
use starship::modules;
+use std::fs;
+use tempfile::TempDir;
fn char_segment(c: &mut Criterion) {
let args = App::new("starship")
@@ -40,5 +42,28 @@ fn line_break_segment(c: &mut Criterion) {
});
}
-criterion_group!(benches, dir_segment, char_segment, line_break_segment);
+fn git_branch_segment(c: &mut Criterion) {
+ let tmp_dir = TempDir::new().unwrap();
+ let repo_dir = tmp_dir.path().join("rocket-controls");
+ fs::create_dir(&repo_dir).unwrap();
+
+ git2::Repository::init(&repo_dir).unwrap();
+
+ let args = App::new("starship")
+ .arg(Arg::with_name("status_code"))
+ .get_matches_from(vec!["starship", "0"]);
+ let context = Context::new_with_dir(args, "~");
+
+ c.bench_function("git_branch segment", move |b| {
+ b.iter(|| modules::handle("git_branch", &context))
+ });
+}
+
+criterion_group!(
+ benches,
+ char_segment,
+ dir_segment,
+ line_break_segment,
+ git_branch_segment
+);
criterion_main!(benches);