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

Feature/catch multiline benchmarks #46

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
14 changes: 9 additions & 5 deletions src/extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ function extractCatch2Result(output: string): BenchmarkResult[] {

const reTestCaseStart = /^benchmark name +samples +iterations +estimated/;
const reBenchmarkStart = /(\d+) +(\d+) +(?:\d+(\.\d+)?) (?:ns|ms|us|s)\s*$/;
const reBenchmarkValues = /^ +(\d+(?:\.\d+)?) (ns|us|ms|s) +(?:\d+(?:\.\d+)?) (?:ns|us|ms|s) +(?:\d+(?:\.\d+)?) (?:ns|us|ms|s)/;
const reBenchmarkValues = /^(.*) +(\d+(?:\.\d+)?) (ns|us|ms|s) +(?:\d+(?:\.\d+)?) (?:ns|us|ms|s) +(?:\d+(?:\.\d+)?) (?:ns|us|ms|s)/;
const reEmptyLine = /^\s*$/;
const reSeparator = /^-+$/;

Expand All @@ -340,7 +340,7 @@ function extractCatch2Result(output: string): BenchmarkResult[] {
}

const extra = `${start[1]} samples\n${start[2]} iterations`;
const name = startLine.slice(0, start.index).trim();
let name = startLine.slice(0, start.index).trim();

const [meanLine, meanLineNum] = nextLine();
const mean = meanLine?.match(reBenchmarkValues);
Expand All @@ -351,8 +351,12 @@ function extractCatch2Result(output: string): BenchmarkResult[] {
);
}

const value = parseFloat(mean[1]);
const unit = mean[2];
const nameAddition = mean[1].trim();
if (nameAddition.trim() !== '') {
name += ' ' + nameAddition.trim();
}
const value = parseFloat(mean[2]);
const unit = mean[3];

const [stdDevLine, stdDevLineNum] = nextLine();
const stdDev = stdDevLine?.match(reBenchmarkValues);
Expand All @@ -363,7 +367,7 @@ function extractCatch2Result(output: string): BenchmarkResult[] {
);
}

const range = '± ' + stdDev[1].trim();
const range = '± ' + stdDev[2].trim();

// Skip empty line
const [emptyLine, emptyLineNum] = nextLine();
Expand Down
31 changes: 26 additions & 5 deletions test/data/extract/catch2_output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ Catch2_bench is a Catch v2.11.0 host application.
Run with -? for options

-------------------------------------------------------------------------------
Fibonacci
Unit_assignment
Construction
-------------------------------------------------------------------------------
/Users/rhayasd/Develop/github.com/rhysd/github-action-benchmark/examples/catch2/catch2_bench.cpp:5
...............................................................................

benchmark name samples iterations estimated
mean low mean high mean
std dev low std dev high std dev
benchmark name samples iterations estimated
mean low mean high mean
std dev low std dev high std dev
-------------------------------------------------------------------------------
Fibonacci 10 100 208 7.1968 ms
344 ns 341 ns 349 ns
Expand All @@ -38,7 +39,27 @@ Fibonacci~ 5! 100 1961

Fibonacci-15_bench 100 20 7.48 ms
3.789 us 3.734 us 3.888 us
362 ns 234 ns 539 ns
362 ns 234 ns 539 ns

-------------------------------------------------------------------------------
Even More Fibonacci
With a long name
-------------------------------------------------------------------------------
/Users/rhayasd/Develop/github.com/rhysd/github-action-benchmark/examples/catch2/catch2_bench.cpp:26
...............................................................................

benchmark name samples iterations estimated
mean low mean high mean
std dev low std dev high std dev
-------------------------------------------------------------------------------
Fibonacci 10 with 100 208 7.1968 ms
a long name 344 ns 341 ns 349 ns
19 ns 11 ns 29 ns

Fibonacci 20 100 2 8.3712 ms
41.731 us 41.25 us 42.622 us
3.256 us 2.163 us 5.353 us



===============================================================================
Expand Down
14 changes: 14 additions & 0 deletions test/extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,20 @@ describe('extractResult()', function() {
value: 3.789,
extra: '100 samples\n20 iterations',
},
{
name: 'Fibonacci 10 with a long name',
range: '± 19',
unit: 'ns',
value: 344,
extra: '100 samples\n208 iterations',
},
{
name: 'Fibonacci 20',
range: '± 3.256',
unit: 'us',
value: 41.731,
extra: '100 samples\n2 iterations',
},
],
},
{
Expand Down