Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix trailing whitespace characters in cargo benchmarks #97

Merged
merged 1 commit into from
Dec 31, 2021
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
2 changes: 1 addition & 1 deletion src/extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ function extractCargoResult(output: string): BenchmarkResult[] {
continue;
}

const name = m[1];
const name = m[1].trim();
const value = parseInt(m[2].replace(reComma, ''), 10);
const range = m[3].replace(reComma, '');

Expand Down
4 changes: 4 additions & 0 deletions test/data/extract/cargo_output2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
test bench_engine_new ... bench: 211,834 ns/iter (+/- 70,126)
test bench_engine_new_raw ... bench: 197 ns/iter (+/- 18)
test bench_engine_new_raw_core ... bench: 196 ns/iter (+/- 31)
test bench_engine_register_fn ... bench: 493 ns/iter (+/- 82)
32 changes: 31 additions & 1 deletion test/extract.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,36 @@ describe('extractResult()', function () {
},
],
},
{
tool: 'cargo',
file: 'cargo_output2.txt',
expected: [
{
name: 'bench_engine_new',
range: '± 70126',
unit: 'ns/iter',
value: 211834,
},
{
name: 'bench_engine_new_raw',
range: '± 18',
unit: 'ns/iter',
value: 197,
},
{
name: 'bench_engine_new_raw_core',
range: '± 31',
unit: 'ns/iter',
value: 196,
},
{
name: 'bench_engine_register_fn',
range: '± 82',
unit: 'ns/iter',
value: 493,
},
],
},
{
tool: 'cargo',
file: 'criterion_output.txt',
Expand Down Expand Up @@ -346,7 +376,7 @@ describe('extractResult()', function () {
];

for (const test of normalCases) {
it(`extracts benchmark output from ${test.tool}`, async function () {
it(`extracts benchmark output from ${test.tool}${test.file ? ` - ${test.file}` : ''}`, async function () {
const file = test.file ?? `${test.tool}_output.txt`;
const outputFilePath = path.join(__dirname, 'data', 'extract', file);
const config = {
Expand Down