The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/pkg/tsdb/influxdb/response_parser_bench_test.go

29 lines
711 B

package influxdb
import (
_ "embed"
"strings"
"testing"
"github.com/stretchr/testify/require"
)
//go:embed testdata/response.json
var testResponse string
// go test -benchmem -run=^$ -memprofile memprofile.out -count=10 -bench ^BenchmarkParseJson$ github.com/grafana/grafana/pkg/tsdb/influxdb
// go tool pprof -http=localhost:9999 memprofile.out
func BenchmarkParseJson(b *testing.B) {
parser := &ResponseParser{}
query := &Query{}
queries := addQueryToQueries(*query)
b.ResetTimer()
for n := 0; n < b.N; n++ {
buf := strings.NewReader(testResponse)
result := parser.parse(buf, queries)
require.NotNil(b, result.Responses["A"].Frames)
require.NoError(b, result.Responses["A"].Error)
}
}