MCPcopy
hub / github.com/grafana/tempo / BenchmarkSumOverTime

Function BenchmarkSumOverTime

pkg/traceql/engine_metrics_test.go:3083–3108  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

3081}
3082
3083func BenchmarkSumOverTime(b *testing.B) {
3084 totalSpans := 1_000_000
3085 in := make([]Span, 0, totalSpans)
3086 in2 := make([]Span, 0, totalSpans)
3087 minimum := 1e10 // 10 billion
3088 maximun := 1e20 // 100 quintillion
3089
3090 for range totalSpans {
3091 s := time.Duration(randInt(1, 3)) * time.Second
3092 v := randFloat(minimum, maximun)
3093 in = append(in, newMockSpan(nil).WithStartTime(uint64(s)).WithSpanString("foo", "bar").WithSpanFloat("kafka.lag", v).WithDuration(100))
3094 s = time.Duration(randInt(1, 3)) * time.Second
3095 v = randFloat(minimum, maximun)
3096 in2 = append(in2, newMockSpan(nil).WithStartTime(uint64(s)).WithSpanString("foo", "bar").WithSpanFloat("kafka.lag", v).WithDuration(100))
3097 }
3098
3099 req := &tempopb.QueryRangeRequest{
3100 Start: uint64(1 * time.Second),
3101 End: uint64(3 * time.Second),
3102 Step: uint64(1 * time.Second),
3103 Query: "{ } | sum_over_time(span.kafka.lag) by (span.foo)",
3104 }
3105 for b.Loop() {
3106 _, _, _ = runTraceQLMetric(req, in, in2)
3107 }
3108}
3109
3110func BenchmarkHistogramAggregator_Combine(b *testing.B) {
3111 // nolint:gosec // G115

Callers

nothing calls this directly

Calls 10

randIntFunction · 0.85
randFloatFunction · 0.85
newMockSpanFunction · 0.85
runTraceQLMetricFunction · 0.85
DurationMethod · 0.80
WithDurationMethod · 0.80
WithSpanFloatMethod · 0.80
WithSpanStringMethod · 0.80
WithStartTimeMethod · 0.80
LoopMethod · 0.80

Tested by

no test coverage detected