-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
48 additions
and
4 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,38 @@ | ||
// SPDX-License-Identifier: MPL-2.0 | ||
|
||
//! This bench monitors the performance of backtracking and term intersection. | ||
//! | ||
//! Dependencies are constructed in a way that all versions need to be tested before | ||
//! pubgrub can determine that no solution exists. | ||
use criterion::*; | ||
use pubgrub::OfflineDependencyProvider; | ||
use version_ranges::Ranges; | ||
|
||
fn bench(c: &mut Criterion, case: &str, package_count: u32, version_count: u32) { | ||
let mut dependency_provider = OfflineDependencyProvider::<u32, Ranges<u32>>::new(); | ||
let r = Ranges::strictly_lower_than(version_count); | ||
dependency_provider.add_dependencies(0u32, 0u32, [(1u32, r)]); | ||
|
||
for n in 1..package_count { | ||
for v in 0..version_count { | ||
let r = Ranges::strictly_lower_than(v); | ||
dependency_provider.add_dependencies(n, v, [(n + 1, r)]); | ||
} | ||
} | ||
|
||
c.bench_function(case, |b| { | ||
b.iter(|| { | ||
let _ = pubgrub::resolve(&dependency_provider, 0u32, 0u32); | ||
}) | ||
}); | ||
} | ||
|
||
fn bench_group(c: &mut Criterion) { | ||
bench(c, "backtracking_small", 5, 60); | ||
bench(c, "backtracking_medium", 5, 200); | ||
bench(c, "backtracking_large", 5, 500); | ||
} | ||
|
||
criterion_group!(benches, bench_group); | ||
criterion_main!(benches); |
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
// SPDX-License-Identifier: MPL-2.0 | ||
|
||
use std::time::Duration; | ||
|
||
use criterion::*; | ||
|
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 |
---|---|---|
|
@@ -5521,4 +5521,4 @@ | |
18: {}, | ||
19: {}, | ||
}, | ||
} | ||
} |