Source file
src/runtime/trace/annotation_test.go
1
2
3
4
5 package trace_test
6
7 import (
8 "context"
9 "io"
10 . "runtime/trace"
11 "strings"
12 "testing"
13 )
14
15 func TestStartRegionLongString(t *testing.T) {
16
17
18
19
20 Start(io.Discard)
21 defer Stop()
22
23 big := strings.Repeat("x", 70_000)
24 StartRegion(context.Background(), big).End()
25 }
26
27 func BenchmarkStartRegion(b *testing.B) {
28 b.ReportAllocs()
29 ctx, task := NewTask(context.Background(), "benchmark")
30 defer task.End()
31
32 b.RunParallel(func(pb *testing.PB) {
33 for pb.Next() {
34 StartRegion(ctx, "region").End()
35 }
36 })
37 }
38
39 func BenchmarkNewTask(b *testing.B) {
40 b.ReportAllocs()
41 pctx, task := NewTask(context.Background(), "benchmark")
42 defer task.End()
43
44 b.RunParallel(func(pb *testing.PB) {
45 for pb.Next() {
46 _, task := NewTask(pctx, "task")
47 task.End()
48 }
49 })
50 }
51
52 func BenchmarkLog(b *testing.B) {
53 b.ReportAllocs()
54
55 Start(io.Discard)
56 defer Stop()
57
58 ctx := context.Background()
59 for b.Loop() {
60 Log(ctx, "", "")
61 }
62 }
63
View as plain text