Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
559 changes: 355 additions & 204 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ resolver = "2"

[workspace.dependencies]
# Add the `tracing` or `tracing-detail` features to see more of gitoxide in the logs. Useful to see which programs it invokes.
gix = { git = "https://github.com/Byron/gitoxide", rev = "12313f2720bb509cb8fa5d7033560823beafb91c", default-features = false, features = [] }
gix = { git = "https://github.com/Byron/gitoxide", rev = "29898e3010bd3332418c683f2ac96aff5c8e72fa", default-features = false, features = [] }
git2 = { version = "0.18.3", features = [
"vendored-openssl",
"vendored-libgit2",
Expand Down
10 changes: 10 additions & 0 deletions crates/gitbutler-branch-actions/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,17 @@ reqwest = { version = "0.12.4", features = ["json"] }
once_cell = "1.19"
pretty_assertions = "1.4"
gitbutler-testsupport.workspace = true
gix = { workspace = true, features = ["max-performance-safe"] }
gitbutler-git = { workspace = true, features = ["test-askpass-path"] }
glob = "0.3.1"
serial_test = "3.1.1"
tempfile = "3.10"
criterion = "0.5.1"

[features]
## Only enabled when benchmark runs are performed.
benches = ["gitbutler-git/benches"]

[[bench]]
name = "branches"
harness = false
13 changes: 13 additions & 0 deletions crates/gitbutler-branch-actions/benches/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
To run benchmarks, add the `benches` feature.

```shell
cargo bench --features benches
```

It's used to get past a safety check in `gitbutler-git`.

For faster compile times, specify the benchmark file directly, i.e.

```shell
cargo bench --bench branches --features benches
```
54 changes: 54 additions & 0 deletions crates/gitbutler-branch-actions/benches/branches.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
use criterion::{black_box, criterion_group, criterion_main, Criterion, Throughput};
use gitbutler_branch_actions::list_branches;
use gitbutler_command_context::CommandContext;
use gitbutler_project::Project;

pub fn fixture_project(name: &str, script: &str) -> Project {
gitbutler_testsupport::read_only::fixture_project(script, name).unwrap()
}

pub fn benchmark_list_branches(c: &mut Criterion) {
const NUM_BRANCHES: u64 = 300;
for (bench_name, num_references, (repo_name, script_name)) in [
(
"list-branches[many local branches]",
NUM_BRANCHES,
("many-local", "branch-benches.sh"),
),
(
"list-branches[tiny repo]",
3,
("one-vbranch-on-integration-two-remotes", "for-listing.sh"),
),
(
"list-branches[many local branches [packed]]",
NUM_BRANCHES,
("many-local-packed", "branch-benches.sh"),
),
(
"list-branches[many local branches [tracked]]",
NUM_BRANCHES * 2,
("many-local-tracked", "branch-benches.sh"),
),
(
"list-branches[many local branches [tracked & packed]]",
NUM_BRANCHES * 2,
("many-local-tracked-packed", "branch-benches.sh"),
),
] {
let mut group = c.benchmark_group(bench_name);
let project = fixture_project(repo_name, script_name);
let ctx = CommandContext::open(&project).unwrap();
group.throughput(Throughput::Elements(num_references));
group
.bench_function("no filter", |b| {
b.iter(|| list_branches(black_box(&ctx), None, None))
})
.bench_function("name-filter rejecting all", |b| {
b.iter(|| list_branches(black_box(&ctx), None, Some(vec!["not available".into()])))
});
}
}

criterion_group!(benches, benchmark_list_branches);
criterion_main!(benches);
Loading