From 1e1c8823188284d1de183cae19e98e69760aaf3e Mon Sep 17 00:00:00 2001 From: Yunfei He Date: Mon, 13 Jul 2026 17:54:04 +0800 Subject: [PATCH] chore: standardize non-UTF-8 benchmark names --- benches/hot_path_baselines.rs | 14 +++++++------- benchmarks/README.md | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/benches/hot_path_baselines.rs b/benches/hot_path_baselines.rs index 0638c39..095cd7b 100644 --- a/benches/hot_path_baselines.rs +++ b/benches/hot_path_baselines.rs @@ -35,18 +35,18 @@ fn bench_hot_path_baselines(criterion: &mut Criterion) { { let non_utf8 = invalid_unicode_path(); let non_utf8_name = non_utf8.file_name().expect("non-UTF-8 fixture has a file name").to_owned(); - let mut dirty_before_non_utf8 = non_utf8.clone(); - dirty_before_non_utf8.pop(); - dirty_before_non_utf8.push("."); - dirty_before_non_utf8.push(&non_utf8_name); + let mut non_utf8_dirty_before = non_utf8.clone(); + non_utf8_dirty_before.pop(); + non_utf8_dirty_before.push("."); + non_utf8_dirty_before.push(&non_utf8_name); let mut non_utf8_before_dirty_late = non_utf8.clone(); non_utf8_before_dirty_late.push("late"); non_utf8_before_dirty_late.push("."); non_utf8_before_dirty_late.push("file.js"); let mut group = criterion.benchmark_group("normalize/non_utf8"); - group.throughput(Throughput::Bytes(dirty_before_non_utf8.as_os_str().len() as u64)); - group.bench_function("dirty_before_non_utf8", |bencher| { - bencher.iter(|| black_box(black_box(dirty_before_non_utf8.as_path()).normalize())); + group.throughput(Throughput::Bytes(non_utf8_dirty_before.as_os_str().len() as u64)); + group.bench_function("non_utf8_dirty_before", |bencher| { + bencher.iter(|| black_box(black_box(non_utf8_dirty_before.as_path()).normalize())); }); group.throughput(Throughput::Bytes(non_utf8_before_dirty_late.as_os_str().len() as u64)); group.bench_function("non_utf8_before_dirty_late", |bencher| { diff --git a/benchmarks/README.md b/benchmarks/README.md index 7bed2c6..bba69dc 100644 --- a/benchmarks/README.md +++ b/benchmarks/README.md @@ -10,7 +10,7 @@ Every timed benchmark black-boxes both input and output. Setup that is not part Benchmark and allocation scenario names describe inputs and requested output shapes. Keep accepted identities unchanged when an implementation starts borrowing, consumes an owned buffer, or removes an intermediate value. Implementation-specific alternatives may use separate control names only when they measure additional work; do not duplicate an existing timed operation under a mechanism-specific name. Stable public-operation rows let CodSpeed and saved Criterion baselines compare the accepted baseline with later implementations. -If a timed path input cannot be represented losslessly as UTF-8, include `non_utf8` in the leaf benchmark name rather than only in a parent group. GitHub and CodSpeed summaries may show only the leaf name, so each such row must remain recognizable without its full benchmark path. +If a timed path input cannot be represented losslessly as UTF-8, start the leaf benchmark name with `non_utf8` rather than identifying it only in a parent group or later in the name. GitHub and CodSpeed summaries may show only the leaf name, so each such row must remain recognizable without its full benchmark path and sort consistently with the other non-UTF-8 rows. Never add a timed benchmark case in the same PR as the implementation it is intended to measure. First open a behavior-neutral baseline PR containing only the benchmark definition and make sure it produces a valid baseline result. Because the bench profile uses fat LTO, add a new baseline family in a dedicated benchmark binary so its code cannot perturb the layout of existing benchmark binaries. Then open the implementation PR with its base branch set to the baseline PR's branch, so CodSpeed executes the case on both sides and reports the implementation delta instead of labeling the case as new. After the baseline PR merges, rebase or retarget the implementation PR onto the merged commit without combining the two review steps.