-
Notifications
You must be signed in to change notification settings - Fork 1
/
trace_test.go
89 lines (71 loc) · 1.89 KB
/
trace_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package gg_test
import (
"testing"
"github.com/mitranim/gg"
)
func BenchmarkCaptureTrace_shallow(b *testing.B) {
for ind := 0; ind < b.N; ind++ {
gg.Nop1(gg.CaptureTrace(0))
}
}
func BenchmarkCaptureTrace_deep(b *testing.B) {
for ind := 0; ind < b.N; ind++ {
gg.Nop1(trace0())
}
}
func BenchmarkTrace_Frames_shallow(b *testing.B) {
trace := gg.CaptureTrace(0)
b.ResetTimer()
for ind := 0; ind < b.N; ind++ {
gg.Nop1(trace.Frames())
}
}
func BenchmarkTrace_Frames_deep(b *testing.B) {
trace := trace0()
b.ResetTimer()
for ind := 0; ind < b.N; ind++ {
gg.Nop1(trace.Frames())
}
}
func BenchmarkFrames_NameWidth(b *testing.B) {
frames := trace0().Frames()
b.ResetTimer()
for ind := 0; ind < b.N; ind++ {
gg.Nop1(frames.NameWidth())
}
}
func BenchmarkFrames_AppendIndentTableTo(b *testing.B) {
frames := trace0().Frames()
buf := make([]byte, 0, 1<<16)
b.ResetTimer()
for ind := 0; ind < b.N; ind++ {
gg.Nop1(frames.AppendIndentTableTo(buf, 0))
}
}
func BenchmarkFrames_AppendIndentTableTo_rel_path(b *testing.B) {
defer gg.SnapSwap(&gg.TraceSkipLang, true).Done()
defer gg.SnapSwap(&gg.TraceBaseDir, gg.Cwd()).Done()
frames := trace0().Frames()
buf := make([]byte, 0, 1<<16)
b.ResetTimer()
for ind := 0; ind < b.N; ind++ {
gg.Nop1(frames.AppendIndentTableTo(buf, 0))
}
}
func BenchmarkTrace_capture_append(b *testing.B) {
buf := make([]byte, 0, 1<<16)
b.ResetTimer()
for ind := 0; ind < b.N; ind++ {
gg.Nop1(trace0().AppendTo(buf))
}
}
func trace0() gg.Trace { return trace1() }
func trace1() gg.Trace { return trace2() }
func trace2() gg.Trace { return trace3() }
func trace3() gg.Trace { return trace4() }
func trace4() gg.Trace { return trace5() }
func trace5() gg.Trace { return trace6() }
func trace6() gg.Trace { return trace7() }
func trace7() gg.Trace { return trace8() }
func trace8() gg.Trace { return trace9() }
func trace9() gg.Trace { return gg.CaptureTrace(0) }