Skip to content

Commit 09cb012

Browse files
committed
Support sub benchmarks
```golang func BenchmarkMerge(b *testing.B) { b.Run("hash", func(b *testing.B) { } b.Run("array", func(b *testing.B) { } } ``` Would generate output: ``` BenchmarkMerge/hash-4 BenchmarkMerge/array-4 ``` Add in the list of valid characters `/` resolve problem
1 parent f9c026b commit 09cb012

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

main_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ var bTests = []struct {
1515
{"BenchmarkF2_F0000000-4 50000000 29.4 ns/op", "F2", "F0000000", 29.4},
1616
{"BenchmarkF0_FF-2 10000000 37.4 ns/op", "F0", "FF", 37.4},
1717
{"BenchmarkF_0-2 40000000 11.2 ns/op", "F", "0", 11.2},
18+
{"BenchmarkAccessStructure/Hash_100-4 40000000 11.2 ns/op", "AccessStructure/Hash", "100", 11.2},
1819
}
1920

2021
func TestParser(t *testing.T) {

parse.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88

99
// Coder should use following naming convention for Benchmark functions
1010
// Naming convention: Benchmark[Function_name]_[Function_argument](b *testing.B)
11-
var re *regexp.Regexp = regexp.MustCompile(`Benchmark([a-zA-Z0-9]+)_([_a-zA-Z0-9]+)-([0-9]+)$`)
11+
var re *regexp.Regexp = regexp.MustCompile(`Benchmark([a-zA-Z0-9/]+)_([_a-zA-Z0-9]+)-([0-9]+)$`)
1212

1313
// Storage for Func(Arg)=Result relations
1414
type BenchArgSet map[string]float64

0 commit comments

Comments
 (0)