influxdb/kit/tracing/tracing_test.go

40 lines
866 B
Go
Raw Normal View History

2019-03-05 00:38:10 +00:00
package tracing
import (
"context"
"testing"
"github.com/opentracing/opentracing-go"
2019-03-05 00:38:10 +00:00
)
/*
BenchmarkStartSpanFromContext-8 1000000 1086 ns/op
BenchmarkOpentracingStartSpanFromContext-8 20000000 73.2 ns/op
*/
func BenchmarkStartSpanFromContext(b *testing.B) {
// Using noop tracer (default).
withRuntimeOverhead := func(ctx context.Context) {
span, _ := StartSpanFromContext(ctx)
span.Finish()
}
for n := 0; n < b.N; n++ {
ctx := context.Background()
withRuntimeOverhead(ctx)
}
}
func BenchmarkOpentracingStartSpanFromContext(b *testing.B) {
// Using noop tracer (default).
withStaticOperationName := func(ctx context.Context) {
span, _ := opentracing.StartSpanFromContext(ctx, "operation name")
span.Finish()
}
for n := 0; n < b.N; n++ {
ctx := context.Background()
withStaticOperationName(ctx)
}
}