diff options
author | Matan Kushner <hello@matchai.me> | 2019-04-19 16:57:14 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-19 16:57:14 -0400 |
commit | 022e0002e40d9286677ae59e751b4b873dce6e95 (patch) | |
tree | 3769e569da5bbdeeb1c9c9759806deea5e1608f6 /benches | |
parent | 6d7485cf5017d05596db85ce49bc979ee3319057 (diff) |
Use "context" to contain run details (#14)
* Create "context" to contain run details
* Use context in tests and benchmarks
Diffstat (limited to 'benches')
-rw-r--r-- | benches/my_benchmark.rs | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/benches/my_benchmark.rs b/benches/my_benchmark.rs index c357554dd..e16c8cab0 100644 --- a/benches/my_benchmark.rs +++ b/benches/my_benchmark.rs @@ -4,18 +4,17 @@ extern crate criterion; use criterion::Criterion; use clap::{App, Arg}; +use starship::context::Context; use starship::modules; -use std::path::Path; fn char_segment(c: &mut Criterion) { let args = App::new("starship") .arg(Arg::with_name("status_code")) .get_matches_from(vec!["starship", "0"]); - - let path = Path::new("~"); + let context = Context::new_with_dir(args, "~"); c.bench_function("char segment", move |b| { - b.iter(|| modules::handle("char", &path, &args)) + b.iter(|| modules::handle("char", &context)) }); } @@ -23,11 +22,10 @@ fn dir_segment(c: &mut Criterion) { let args = App::new("starship") .arg(Arg::with_name("status_code")) .get_matches_from(vec!["starship", "0"]); - - let path = Path::new("~"); + let context = Context::new_with_dir(args, "~"); c.bench_function("dir segment", move |b| { - b.iter(|| modules::handle("dir", &path, &args)) + b.iter(|| modules::handle("dir", &context)) }); } @@ -35,11 +33,10 @@ fn line_break_segment(c: &mut Criterion) { let args = App::new("starship") .arg(Arg::with_name("status_code")) .get_matches_from(vec!["starship", "0"]); - - let path = Path::new("~"); + let context = Context::new_with_dir(args, "~"); c.bench_function("line break segment", move |b| { - b.iter(|| modules::handle("line_break", &path, &args)) + b.iter(|| modules::handle("line_break", &context)) }); } |