• Hana Kim's avatar
    runtime/trace: add simple benchmarks for user annotation · 3bf16444
    Hana Kim authored
    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/109115Reviewed-by: 's avatarPeter Weinberger <pjw@google.com>
    3bf16444
trace_stack_test.go 7.82 KB