Documentation ¶
Index ¶
- func GetBenchmark(b *testing.B) *scopetesting.Benchmark
- func GetContextFromTest(t *testing.T) context.Context
- func GetTest(t *testing.T) *scopetesting.Test
- func Run(m *testing.M, opts ...agent.Option) int
- func SetTestCodeFromCaller(t *testing.T)
- func SetTestCodeFromCallerSkip(t *testing.T, skip int)
- func SetTestCodeFromFunc(t *testing.T, fn interface{})
- func StartBenchmark(b *testing.B, benchFunc func(b *testing.B))
- func StartTest(t *testing.T, opts ...scopetesting.Option) *scopetesting.Test
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetBenchmark ¶
func GetBenchmark(b *testing.B) *scopetesting.Benchmark
Gets the *Benchmark from a *testing.B
func GetContextFromTest ¶
Gets the context from a test
func Run ¶
Helper function to run a `testing.M` object and gracefully stopping the agent afterwards
func SetTestCodeFromCaller ¶ added in v0.2.0
Sets the test code from the caller of this func
func SetTestCodeFromCallerSkip ¶ added in v0.2.0
Sets the test code from the caller of this func
func SetTestCodeFromFunc ¶ added in v0.2.0
Sets the test code from a func
func StartBenchmark ¶
Instruments the given benchmark func
Example of usage:
func factorial(value int) int { if value == 1 { return 1 } return value * factorial(value-1) }
func BenchmarkFactorial(b *testing.B) { scopeagent.StartBenchmark(b, func(b *testing.B) { for i := 0; i < b.N; i++ { _ = factorial(25) } } }
func BenchmarkFactorialWithSubBenchmarks(b *testing.B) { res := 0 b.Run("25", func(b *testing.B) { scopeagent.StartBenchmark(b, func(b *testing.B) { for i := 0; i < b.N; i++ { res = factorial(25) } }) }) b.Run("50", func(b *testing.B) { scopeagent.StartBenchmark(b, func(b *testing.B) { for i := 0; i < b.N; i++ { res = factorial(50) } }) }) b.Run("75", func(b *testing.B) { scopeagent.StartBenchmark(b, func(b *testing.B) { for i := 0; i < b.N; i++ { res = factorial(75) } }) }) b.Run("100", func(b *testing.B) { scopeagent.StartBenchmark(b, func(b *testing.B) { for i := 0; i < b.N; i++ { res = factorial(100) } }) }) _ = res }
func StartTest ¶
func StartTest(t *testing.T, opts ...scopetesting.Option) *scopetesting.Test
Instruments the given test, returning a `Test` object that can be used to extend the test trace
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.