Skip to content

Commit 9b76dbf

Browse files
authored
Merge pull request #14 from cryspen/wysiwys/group-separator
Allow Criterion group separator in name
2 parents 8bea9e6 + f251a9b commit 9b76dbf

File tree

6 files changed

+35
-6
lines changed

6 files changed

+35
-6
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Currently supported sources:
1515

1616
## Metadata format
1717

18-
The benchmark name in the `cargo` benchmarks can be provided as a `,`-separated string where each item represents a key-value pair with the format `key=value`, e.g. `category=ML-KEM,keySize=44,name=PK Validation,platform=neon,api=unpacked`.
18+
The benchmark name in the `cargo` benchmarks can be provided as a `,`-separated string where each item represents a key-value pair with the format `key=value`, e.g. `category=ML-KEM,keySize=44,name=PK Validation,platform=neon,api=unpacked`. Additionally, one of these separators may be a `/`, where the left-hand side represents the keys configured for a Criterion group, and the right-hand side represents the keys for a benchmark function on that group, e.g. `category=ML-KEM,keySize=44,name=PK Validation/platform=neon,api=unpacked`. Aside from this separator, no other `/` characters should be included in the name.
1919

2020
Alternatively, the benchmark name can be provided as a simple string, which will then be set as the value of the `name` key. This will only happen if there are no `key=value` pairs found in the benchmark name.
2121

scripts/prepare-release.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ cp -R node_modules .release/node_modules
5050

5151
git checkout "$version"
5252
git pull
53-
git rm -rf node_modules
53+
git rm -rf --ignore-unmatch node_modules
5454
rm -rf node_modules # remove node_modules/.cache
5555

5656
rm -rf dist

src/extract.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,14 @@ export interface BenchmarkResult {
1414
}
1515

1616
function addNameMetadataToResult(result: BenchmarkResult, nameString: string) {
17-
// split by separator
18-
const keyValuePairs = nameString.split(',');
17+
// replace first '/'
18+
// only one is allowed, as a Criterion group/function separator
19+
const nameStringProcessed = nameString.replace('/', ',');
20+
21+
if (nameStringProcessed.includes('/')) {
22+
throw new Error("Only one '/' is allowed as a group/function separator");
23+
}
24+
const keyValuePairs = nameStringProcessed.split(',');
1925

2026
let foundAtLeastOne = false;
2127

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
WARNING: HTML report generation will become a non-default optional feature in Criterion.rs 0.4.0.
2+
This feature is being moved to cargo-criterion (https://github.com/bheisler/cargo-criterion) and will be optional in a future version of Criterion.rs. To silence this warning, either switch to cargo-criterion or enable the 'html_reports' feature in your Cargo.toml.
3+
4+
Gnuplot not found, using plotters backend
5+
test category=ML-KEM,keySize=1024,name=PK Validation ... bench: 329 ns/iter (+/- 4)
6+
7+
test category=ML-KEM,keySize=512/name=PK Validation/platform=neon,api=unpacked ... bench: 3268 ns/iter (+/- 47)
8+
9+
test category=ML-KEM,keySize=768,name=PK Validation/platform=neon,api=unpacked ... bench: 12314 ns/iter (+/- 123)
10+
11+
12+
Warning: Unable to complete 100 samples in 5.0s. You may wish to increase target time to 8.5s, enable flat sampling, or reduce sample count to 50.
13+
test category=ML-KEM,keySize=512,name=PK Validation,platform=neon,api=unpacked (external random) ... bench: 1672496 ns/iter (+/- 10166)
14+

test/data/extract/criterion_output_with_metadata_format.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ This feature is being moved to cargo-criterion (https://github.com/bheisler/carg
44
Gnuplot not found, using plotters backend
55
test category=ML-KEM,keySize=1024,name=PK Validation ... bench: 329 ns/iter (+/- 4)
66

7-
test category=ML-KEM,keySize=512,name=PK Validation,platform=neon,api=unpacked ... bench: 3268 ns/iter (+/- 47)
7+
test category=ML-KEM,keySize=512,name=PK Validation/platform=neon,api=unpacked ... bench: 3268 ns/iter (+/- 47)
88

9-
test category=ML-KEM,keySize=768,name=PK Validation,platform=neon,api=unpacked ... bench: 12314 ns/iter (+/- 123)
9+
test category=ML-KEM,keySize=768,name=PK Validation/platform=neon,api=unpacked ... bench: 12314 ns/iter (+/- 123)
1010

1111

1212
Warning: Unable to complete 100 samples in 5.0s. You may wish to increase target time to 8.5s, enable flat sampling, or reduce sample count to 50.

test/extract.spec.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,15 @@ describe('extractData()', function () {
8282
} as Config;
8383
await A.rejects(extractData(config), /^Error: No benchmark result was found in /);
8484
});
85+
86+
it('raises an error when more than one / separator', async function () {
87+
const config = {
88+
os: 'ubuntu-latest',
89+
tool: 'cargo',
90+
outputFilePath: path.join(__dirname, 'data', 'extract', 'criterion_invalid.txt'),
91+
} as Config;
92+
await A.rejects(extractData(config), /^Error: Only one '\/' is allowed as a group\/function separator/);
93+
});
8594
});
8695

8796
describe('localWriteBenchmark()', function () {

0 commit comments

Comments
 (0)