Created
June 26, 2020 14:29
-
-
Save kylebrandt/f4338476c502e34fc40755e443dbee74 to your computer and use it in GitHub Desktop.
random_insights_bench
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
benchcmp <(/usr/local/go/bin/go test -benchmem -run=^$ github.com/grafana/grafana/pkg/tsdb/azuremonitor -bench '^(BenchmarkOldInsights)$' -v | sed 's/BenchmarkOldInsights/BenchmarkInsightsMetricsResultToFrame/g') <(/usr/local/go/bin/go test -benchmem -run=^$ github.com/grafana/grafana/pkg/tsdb/azuremonitor -bench '^(BenchmarkInsightsMetricsResultToFrame)$' -v) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
benchcmp <(/usr/local/go/bin/go test -benchmem -run=^$ github.com/grafana/grafana/pkg/tsdb/azuremonitor -bench '^(BenchmarkOldInsights)$' -v | sed 's/BenchmarkOldInsights/BenchmarkInsightsMetricsResultToFrame/g') <(/usr/local/go/bin/go test -benchmem -run=^$ github.com/grafana/grafana/pkg/tsdb/azuremonitor -bench '^(BenchmarkInsightsMetricsResultToFrame)$' -v) | |
benchmark old ns/op new ns/op delta | |
BenchmarkInsightsMetricsResultToFrame-8 11016198 4370087 -60.33% | |
benchmark old allocs new allocs delta | |
BenchmarkInsightsMetricsResultToFrame-8 105147 55087 -47.61% | |
benchmark old bytes new bytes delta | |
BenchmarkInsightsMetricsResultToFrame-8 7648039 2395678 -68.68% |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl "https://api.applicationinsights.io/v1/apps/DEMO_APP/metrics/traces/count?timespan=PT12H&interval=PT1M&aggregation=sum&segment=client%2FcountryOrRegion,client%2Fcity" -H "x-api-key: DEMO_KEY" > ~/tmp/bigger.json |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func BenchmarkInsightsMetricsResultToFrame(b *testing.B) { | |
res, err := loadInsightsMetricsResponse("applicationinsights/bigger.json") | |
require.NoError(b, err) | |
for n := 0; n < b.N; n++ { | |
_, err = InsightsMetricsResultToFrame(res, "traces/count", "sum", []string{"client/countryOrRegion", "client/city"}) | |
require.NoError(b, err) | |
} | |
} | |
func BenchmarkOldInsights(b *testing.B) { | |
data, err := ioutil.ReadFile("testdata/applicationinsights/bigger.json") | |
require.NoError(b, err) | |
query := &ApplicationInsightsQuery{ | |
IsRaw: false, | |
} | |
datasource := &ApplicationInsightsDatasource{} | |
require.NoError(b, err) | |
for n := 0; n < b.N; n++ { | |
_, err := datasource.parseTimeSeriesFromMetrics(data, query) | |
require.NoError(b, err) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Actually not valid since parseTimeSeriesFrom Metrics loads the JSON, changing the bench so that is done once before the function actually means the newer one slower: