aboutsummaryrefslogtreecommitdiff
path: root/src/testing/helper_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/testing/helper_test.go')
-rw-r--r--src/testing/helper_test.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/testing/helper_test.go b/src/testing/helper_test.go
index 7ce58c67fb..8858196cf0 100644
--- a/src/testing/helper_test.go
+++ b/src/testing/helper_test.go
@@ -70,3 +70,34 @@ func TestTBHelperParallel(t *T) {
t.Errorf("got output line %q; want %q", got, want)
}
}
+
+type noopWriter int
+
+func (nw *noopWriter) Write(b []byte) (int, error) { return len(b), nil }
+
+func BenchmarkTBHelper(b *B) {
+ w := noopWriter(0)
+ ctx := newTestContext(1, newMatcher(regexp.MatchString, "", ""))
+ t1 := &T{
+ common: common{
+ signal: make(chan bool),
+ w: &w,
+ },
+ context: ctx,
+ }
+ f1 := func() {
+ t1.Helper()
+ }
+ f2 := func() {
+ t1.Helper()
+ }
+ b.ResetTimer()
+ b.ReportAllocs()
+ for i := 0; i < b.N; i++ {
+ if i&1 == 0 {
+ f1()
+ } else {
+ f2()
+ }
+ }
+}