Source file
src/runtime/trace/annotation_test.go
1
2
3
4
5 package trace_test
6
7 import (
8 "context"
9 . "runtime/trace"
10 "testing"
11 )
12
13 func BenchmarkStartRegion(b *testing.B) {
14 b.ReportAllocs()
15 ctx, task := NewTask(context.Background(), "benchmark")
16 defer task.End()
17
18 b.RunParallel(func(pb *testing.PB) {
19 for pb.Next() {
20 StartRegion(ctx, "region").End()
21 }
22 })
23 }
24
25 func BenchmarkNewTask(b *testing.B) {
26 b.ReportAllocs()
27 pctx, task := NewTask(context.Background(), "benchmark")
28 defer task.End()
29
30 b.RunParallel(func(pb *testing.PB) {
31 for pb.Next() {
32 _, task := NewTask(pctx, "task")
33 task.End()
34 }
35 })
36 }
37
View as plain text