Skip to content

Grouping

Benchmark names often contain structured information beyond a simple label. A name like BenchmarkSort/1024/QuickSort encodes the function, the input size, and the algorithm variant. Grouping is the process of extracting these dimensions — Name, XAxis, and YAxis — from benchmark names so vizb can chart them meaningfully.

Without grouping, every benchmark is treated as a flat label. With grouping, vizb understands which benchmarks belong together, what goes on each axis, and how to organize charts into logical groups.

Grouping creates multi-dimensional charts. Without grouping, all benchmarks produce a single flat list — every result is an isolated bar or point. With grouping, vizb can:

  • Separate charts by logical category (e.g., one chart per algorithm)
  • Populate axes with meaningful values (e.g., input size on the X-axis)
  • Create series for test case variants (e.g., different data distributions on the Y-axis)
Without GroupingWith Grouping
Single flat chart with all benchmarksMultiple charts grouped by name
No axis structureX-axis and Y-axis with meaningful categories
Hard to compare across dimensionsEasy side-by-side comparison

Grouping extracts up to three dimensions from each benchmark name:

DimensionFlag ComponentDescription
Name (name / n)Groups benchmarks into separate chartsBenchmarks sharing the same name appear in the same chart
XAxis (xAxis / x)Sets the X-axis categoriesEach unique value becomes a tick on the X-axis
YAxis (yAxis / y)Creates test case variantsEach unique value becomes a separate series or bar group

The --group-pattern flag splits benchmark names using a separator (/ or _) and assigns each segment to a dimension.

  • / — slash separator (the Go benchmark convention)
  • _ — underscore separator
ComponentShorthandMeaning
namenChart group name
xAxisxX-axis values
yAxisyY-axis series

Slash-separated n/x/y:

Terminal window
vizb bench.txt --group-pattern "n/x/y" -o output.html
Benchmark NameNameXAxisYAxis
BenchmarkSort/1024/QuickSortSort1024QuickSort
BenchmarkSort/2048/MergeSortSort2048MergeSort
BenchmarkSort/4096/QuickSortSort4096QuickSort

Underscore-separated n_y_x:

Terminal window
vizb bench.txt --group-pattern "n_y_x" -o output.html
Benchmark NameNameYAxisXAxis
BenchmarkHash_SHA256_1KBHashSHA2561KB
BenchmarkHash_MD5_4KBHashMD54KB

2D with n/y (no X-axis grouping):

Terminal window
vizb bench.txt --group-pattern "n/y" -o output.html
Benchmark NameNameYAxis
BenchmarkJSON/MarshalJSONMarshal
BenchmarkJSON/UnmarshalJSONUnmarshal

Prefix skip with /n/y (leading slash discards the first segment):

Terminal window
vizb bench.txt --group-pattern "/n/y" -o output.html
Benchmark NameNameYAxis
BenchmarkTest/JSON/MarshalJSONMarshal
BenchmarkTest/XML/ParseXMLParse

The --group-regex flag uses Go-style named capture groups for full flexibility. Use this when your benchmark names do not follow a simple separator pattern.

Group NameShorthandDimension
(?<name>...)(?<n>...)Chart group name
(?<xAxis>...)(?<x>...)X-axis values
(?<yAxis>...)(?<y>...)Y-axis series
Benchmark NameRegexExtracted
BenchmarkHashing64MD5Hashing64(?<x>.*)X: MD5
BenchmarkJSONByMarshal(?<x>.*)By(?<y>.*)X: JSON, Y: Marshal
BenchmarkDecode/text=digits/level=speed(?<n>.*)/text=(?<x>.*)/level=(?<y>.*)N: Decode, X: digits, Y: speed
Terminal window
vizb bench.txt --group-regex "(?<n>.*)/text=(?<x>.*)/level=(?<y>.*)" -o output.html

Use --group-pattern when benchmark names follow a consistent separator format (/ or _).

Terminal window
vizb bench.txt --group-pattern "n/x/y" -o output.html

Best for standard Go benchmarks where sub-benchmarks use slash-separated names like BenchmarkFunc/size/variant.