Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add benchmarks testing the constructors
- Loading branch information
Showing
2 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#[macro_use] | ||
extern crate bencher; | ||
extern crate directories; | ||
|
||
use bencher::Bencher; | ||
use bencher::black_box; | ||
use directories::BaseDirs; | ||
use directories::ProjectDirs; | ||
use directories::UserDirs; | ||
|
||
fn base_dirs(b: &mut Bencher) { | ||
b.iter(|| { | ||
let _ = black_box(BaseDirs::new()); | ||
}); | ||
} | ||
|
||
fn user_dirs(b: &mut Bencher) { | ||
b.iter(|| { | ||
let _ = black_box(UserDirs::new()); | ||
}); | ||
} | ||
|
||
fn project_dirs_from_path(b: &mut Bencher) { | ||
b.iter(|| { | ||
let _ = black_box(ProjectDirs::from_path(Default::default())); | ||
}); | ||
} | ||
|
||
fn project_dirs(b: &mut Bencher) { | ||
b.iter(|| { | ||
let _ = black_box(ProjectDirs::from("org", "foo", "Bar App")); | ||
}); | ||
} | ||
|
||
benchmark_group!(constructors, | ||
base_dirs, | ||
user_dirs, | ||
project_dirs_from_path, | ||
project_dirs, | ||
); | ||
benchmark_main!(constructors); |