From b20f84d72d2fd1df000e13ca45ee1cd3743e8b6b Mon Sep 17 00:00:00 2001 From: Andy Cook Date: Sat, 13 Aug 2022 13:44:06 +0200 Subject: [PATCH] Allow more characters in Golang bench outputs This adds , and = as acceptable characters as Go benchmark names. Previously benchmarks with these character were not detected by this action. --- src/extract.ts | 2 +- test/data/extract/go_output.txt | 11 ++++++----- test/extract.spec.ts | 6 ++++++ 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/extract.ts b/src/extract.ts index 49e4349e2..6cb2ede90 100644 --- a/src/extract.ts +++ b/src/extract.ts @@ -306,7 +306,7 @@ function extractGoResult(output: string): BenchmarkResult[] { // Example: // BenchmarkFib20-8 30000 41653 ns/op // BenchmarkDoWithConfigurer1-8 30000000 42.3 ns/op - const reExtract = /^(Benchmark\w+(?:\/?[\w()$%^&*-]*?)*?)(-\d+)?\s+(\d+)\s+([0-9.]+)\s+(.+)$/; + const reExtract = /^(Benchmark\w+(?:\/?[\w()$%^&*-=,]*?)*?)(-\d+)?\s+(\d+)\s+([0-9.]+)\s+(.+)$/; for (const line of lines) { const m = line.match(reExtract); diff --git a/test/data/extract/go_output.txt b/test/data/extract/go_output.txt index 6472966f9..c87a250f3 100644 --- a/test/data/extract/go_output.txt +++ b/test/data/extract/go_output.txt @@ -1,9 +1,10 @@ goos: darwin goarch: amd64 -BenchmarkFib10-8 5000000 325 ns/op -BenchmarkFib20 30000 40537.123 ns/op -BenchmarkFib/my_tabled_benchmark_-_10-8 5000000 325 ns/op -BenchmarkFib/my_tabled_benchmark_-_20 30000 40537.123 ns/op -BenchmarkFib/my/tabled/benchmark_-_20 30001 40537.456 ns/op +BenchmarkFib10-8 5000000 325 ns/op +BenchmarkFib20 30000 40537.123 ns/op +BenchmarkFib/my_tabled_benchmark_-_10-8 5000000 325 ns/op +BenchmarkFib/my_tabled_benchmark_-_20 30000 40537.123 ns/op +BenchmarkFib/my/tabled/benchmark_-_20 30001 40537.456 ns/op +BenchmarkFib/my/tabled/benchmark_-_20,var1=13,var2=14 30001 40537.456 ns/op PASS ok _/Users/rhayasd/Develop/github.com/benchmark-action/github-action-benchmark/examples/go 3.614s diff --git a/test/extract.spec.ts b/test/extract.spec.ts index 1532d1af0..81738b249 100644 --- a/test/extract.spec.ts +++ b/test/extract.spec.ts @@ -199,6 +199,12 @@ describe('extractResult()', function () { value: 40537.456, extra: '30001 times', }, + { + name: 'BenchmarkFib/my/tabled/benchmark_-_20,var1=13,var2=14', + unit: 'ns/op', + value: 40537.456, + extra: '30001 times', + }, ], }, {