diff options
| author | Hana Kim <hakim@google.com> | 2018-04-24 12:42:47 -0400 |
|---|---|---|
| committer | Hyang-Ah Hana Kim <hyangah@gmail.com> | 2018-04-24 17:43:19 +0000 |
| commit | 3bf16444283094bf03a96fa76f3c5dd4c84867b2 (patch) | |
| tree | a47f63e867d3d91435fe509070b04cdebd03d7c7 /src/runtime/trace/trace_stack_test.go | |
| parent | c2d10243688194346f660591fe4159e30a8d20ec (diff) | |
| download | go-3bf16444283094bf03a96fa76f3c5dd4c84867b2.tar.xz | |
runtime/trace: add simple benchmarks for user annotation
Also, avoid Region creation when tracing is disabled.
Unfortunate side-effect of this change is that we no longer trace
pre-existing regions in tracing, but we can add the feature in
the future when we find it useful and justifiable. Until then,
let's avoid the overhead from this low-level api use as much as
possible.
goos: linux
goarch: amd64
pkg: runtime/trace
// Trace disabled
BenchmarkStartRegion-12 2000000000 0.66 ns/op 0 B/op 0 allocs/op
BenchmarkNewTask-12 30000000 40.4 ns/op 56 B/op 2 allocs/op
// Trace enabled, -trace=/dev/null
BenchmarkStartRegion-12 5000000 287 ns/op 32 B/op 1 allocs/op
BenchmarkNewTask-12 5000000 283 ns/op 56 B/op 2 allocs/op
Also, skip other tests if tracing is already enabled.
Change-Id: Id3028d60b5642fcab4b09a74fd7d79361a3861e5
Reviewed-on: https://go-review.googlesource.com/109115
Reviewed-by: Peter Weinberger <pjw@google.com>
Diffstat (limited to 'src/runtime/trace/trace_stack_test.go')
| -rw-r--r-- | src/runtime/trace/trace_stack_test.go | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/runtime/trace/trace_stack_test.go b/src/runtime/trace/trace_stack_test.go index e7b8d57659..62c06e67d9 100644 --- a/src/runtime/trace/trace_stack_test.go +++ b/src/runtime/trace/trace_stack_test.go @@ -24,7 +24,7 @@ import ( // In particular that we strip bottom uninteresting frames like goexit, // top uninteresting frames (runtime guts). func TestTraceSymbolize(t *testing.T) { - testenv.MustHaveGoBuild(t) + skipTraceSymbolizeTestIfNecessary(t) buf := new(bytes.Buffer) if err := Start(buf); err != nil { @@ -285,6 +285,13 @@ func TestTraceSymbolize(t *testing.T) { } } +func skipTraceSymbolizeTestIfNecessary(t *testing.T) { + testenv.MustHaveGoBuild(t) + if IsEnabled() { + t.Skip("skipping because -test.trace is set") + } +} + func dumpEventStacks(typ byte, events []*trace.Event) ([]byte, int) { matched := 0 o := new(bytes.Buffer) |
