func init() { … } // BenchmarkRecursion measures the overhead of adding calling a function // recursively with just the depth parameter. func BenchmarkRecursion(b *testing.B) { … } //go:noinline func recurse(depth int) { … } // BenchmarkRecursionWithLogger measures the overhead of adding a logr.Logger // parameter. func BenchmarkRecursionWithLogger(b *testing.B) { … } //go:noinline func recurseWithLogger(logger logr.Logger, depth int) { … } // BenchmarkRecursionWithContext measures the overhead of adding a context // parameter. func BenchmarkRecursionWithContext(b *testing.B) { … } //go:noinline func recurseWithContext(ctx context.Context, depth int) { … } // BenchmarkRecursionWithLogger measures the overhead of adding a logr.Logger // parameter and using it once. func BenchmarkRecursionWithLoggerAndLog(b *testing.B) { … } //go:noinline func recurseWithLoggerAndLog(logger logr.Logger, depth int) { … } // BenchmarkRecursionWithContext measures the overhead of adding a context // parameter and using it once to retrieve and call a logger. func BenchmarkRecursionWithContextAndLog(b *testing.B) { … } //go:noinline func recurseWithContextAndLog(ctx context.Context, depth int) { … } // BenchmarkNestedContextWithTimeouts benchmarks how quickly a function can be // called that creates a new context at each call with context.WithTimeout. func BenchmarkNestedContextWithTimeouts(b *testing.B) { … } //go:noinline func nestedContextWithTimeout(ctx context.Context, depth int) { … } // BenchmarkNestedContextWithTimeouts benchmarks how quickly a function can be // called that creates a new context at each call with context.WithTimeout // and then looks up a logger. func BenchmarkNestedContextWithTimeoutsAndLookup(b *testing.B) { … } //go:noinline func nestedContextWithTimeoutAndLookup(ctx context.Context, depth int) { … } var logger … // BenchmarkNestedContextWithTimeouts benchmarks how quickly FromContextOrDiscard // can look up a logger in nested contexts where WithTimeouts is used to // created those nested contexts. func BenchmarkLookupWithTimeouts(b *testing.B) { … } type keyT … var key … // BenchmarkNestedContextWithTimeouts benchmarks how quickly FromContextOrDiscard // can look up a logger in nested contexts where WithValue is used to // created those nested contexts. func BenchmarkLookupWithValues(b *testing.B) { … }