Write a function accepting *testing.B that loops b.N times around your code to measure performance.
Write a benchmark function named BenchmarkX that accepts a *testing.B parameter and loops b.N times around the code you want to measure.
func BenchmarkSplitSeqEmptySeparator(b *testing.B) {
for range b.N {
for range SplitSeq(benchInputHard, nil) {
}
}
}
Run it with go test -bench=BenchmarkSplitSeqEmptySeparator.
A benchmark is a special test that runs your code thousands of times to measure how fast it is. You write a function that loops a specific number of times, and Go automatically calculates the average time per operation. This helps you spot slow code before your users do.