WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 4fabd6b

Browse files
Add slow compose reproducer
1 parent 74b74b0 commit 4fabd6b

File tree

3 files changed

+161
-0
lines changed

3 files changed

+161
-0
lines changed

Cargo.lock

Lines changed: 88 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

josh-core/Cargo.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ keywords = ["git", "monorepo", "workflow", "scm"]
99
readme = "../README.md"
1010
edition = "2024"
1111

12+
[[bench]]
13+
name = "ultrawide"
14+
harness = false
15+
1216
[dependencies]
1317
backtrace = "0.3.76"
1418
bitvec = "1.0.1"
@@ -37,5 +41,9 @@ sled = "0.34.7"
3741
tracing = { workspace = true }
3842
toml = { workspace = true }
3943

44+
[dev-dependencies]
45+
rand = "0.9.2"
46+
criterion2 = { version = "3.0.2" }
47+
4048
[features]
4149
incubating = []

josh-core/benches/ultrawide.rs

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
use criterion::{Criterion, criterion_group, criterion_main};
2+
use itertools::Itertools;
3+
use rand::Rng;
4+
use rand::distr::{Alphabetic, Distribution};
5+
use rand::rngs::ThreadRng;
6+
use std::path::PathBuf;
7+
8+
const N_PATHS: usize = 30;
9+
10+
fn generate_paths() -> Vec<PathBuf> {
11+
const PATH_COMPONENTS_MAX: usize = 10;
12+
const PATH_COMPONENT_LEN: usize = 2;
13+
14+
// Create a single path component -- random lowercase characters,
15+
// length of PATH_COMPONENT_LEN
16+
fn make_path_component(rng: &mut ThreadRng) -> String {
17+
(0..PATH_COMPONENT_LEN)
18+
.map(|_| {
19+
let ch = Alphabetic.sample(rng) as char;
20+
ch.to_ascii_lowercase()
21+
})
22+
.collect()
23+
}
24+
25+
// Create a single path -- anywhere from 1 to PATH_COMPONENTS_MAX components
26+
fn make_path(rng: &mut ThreadRng) -> PathBuf {
27+
let num_components = rng.random_range(1..=PATH_COMPONENTS_MAX);
28+
let mut path = PathBuf::new();
29+
30+
for _ in 0..num_components {
31+
path.push(make_path_component(rng))
32+
}
33+
34+
path
35+
}
36+
37+
let mut rng = rand::rng();
38+
39+
// Finally, create N_PATHS of random paths
40+
(0..N_PATHS).map(|_| make_path(&mut rng)).collect()
41+
}
42+
43+
fn ultrawide(c: &mut Criterion) {
44+
c.bench_function("ultrawide_filter_parse", |b| {
45+
b.iter_with_setup_wrapper(|runner| {
46+
let filter = generate_paths()
47+
.into_iter()
48+
.map(|p| {
49+
let p = p.display().to_string();
50+
format!("::{p}/")
51+
})
52+
.join(",");
53+
54+
let filter = format!(":[{}]", filter);
55+
56+
runner.run(move || {
57+
let filter = josh_core::filter::parse(&filter).expect("failed to parse");
58+
std::hint::black_box(filter);
59+
})
60+
});
61+
});
62+
}
63+
64+
criterion_group!(benches, ultrawide);
65+
criterion_main!(benches);

0 commit comments

Comments
 (0)