-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #10754 - Muscraft:benchsuite, r=epage
Add a benchmark for workspace initialization It [was suggested](#10736 (comment)) that a benchmark for workspace initialization should be added. This was suggested because there were issues with the performance of [workspace inheritance](#10747) as well as a general way to track the workspace initialization time across cargo changes ### Changes - Moved common functions out of `resolve.rs` to a shared `lib.rs` - Added a new struct to be used when creating a new benchmark - This was done because `env!("CARGO_TARGET_TMPDIR")` would fail to compile when put inside of the new `lib.rs` - Added a new workspace test for workspace inheritance - This new workspace does not have a repo that it was built from and if one needs to be made I can change that
- Loading branch information
Showing
5 changed files
with
243 additions
and
192 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
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,27 @@ | ||
use benchsuite::fixtures; | ||
use cargo::core::Workspace; | ||
use criterion::{criterion_group, criterion_main, Criterion}; | ||
|
||
fn workspace_initialization(c: &mut Criterion) { | ||
let fixtures = fixtures!(); | ||
let mut group = c.benchmark_group("workspace_initialization"); | ||
for (ws_name, ws_root) in fixtures.workspaces() { | ||
let config = fixtures.make_config(&ws_root); | ||
// The resolver info is initialized only once in a lazy fashion. This | ||
// allows criterion to skip this workspace if the user passes a filter | ||
// on the command-line (like `cargo bench -- workspace_initialization/tikv`). | ||
group.bench_function(ws_name, |b| { | ||
b.iter(|| Workspace::new(&ws_root.join("Cargo.toml"), &config).unwrap()) | ||
}); | ||
} | ||
group.finish(); | ||
} | ||
|
||
// Criterion complains about the measurement time being too small, but the | ||
// measurement time doesn't seem important to me, what is more important is | ||
// the number of iterations which defaults to 100, which seems like a | ||
// reasonable default. Otherwise, the measurement time would need to be | ||
// changed per workspace. We wouldn't want to spend 60s on every workspace, | ||
// that would take too long and isn't necessary for the smaller workspaces. | ||
criterion_group!(benches, workspace_initialization); | ||
criterion_main!(benches); |
Oops, something went wrong.