Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added new bench target 'bench-fast' #297

Closed
wants to merge 11 commits into from
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,15 @@ bench-new: benchmarks
benchmark: bench-old bench-new
@benchstat benchmarks/old.out benchmarks/new.out

.PHONY : bench-fast
bench-fast: benchmarks
@echo "Benchmarking old engine"
@go test ./engine -bench 'BenchmarkRangeQuery/.*/old_engine' -run none -count 5 -args -fast | sed -u 's/\/old_engine//' > benchmarks/old.out
@go test ./engine -bench 'BenchmarkNativeHistograms/.*/old_engine' -run none -count 5 | sed -u 's/\/old_engine//' >> benchmarks/old.out
@echo "Benchmarking new engine"
@go test ./engine -bench 'BenchmarkRangeQuery/.*/new_engine' -run none -count 5 -args -fast | sed -u 's/\/new_engine//' > benchmarks/new.out
@go test ./engine -bench 'BenchmarkNativeHistograms/.*/new_engine' -run none -count 5 | sed -u 's/\/new_engine//' >> benchmarks/new.out

.PHONY: sync-parser
sync-parser:
@echo "Cleaning existing directories"
Expand Down
18 changes: 18 additions & 0 deletions engine/bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package engine_test

import (
"context"
"flag"
"fmt"
"strconv"
"strings"
Expand Down Expand Up @@ -101,6 +102,10 @@ func BenchmarkSingleQuery(b *testing.B) {
}

func BenchmarkRangeQuery(b *testing.B) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we just use tesitng.Short() for this?


sixHourDatasetOnly := flag.Bool("fast", false, "Only runs six hour dataset")
flag.Parse()

samplesPerHour := 60 * 2
sixHourDataset := setupStorage(b, 1000, 3, 6*samplesPerHour)
defer sixHourDataset.Close()
Expand Down Expand Up @@ -288,6 +293,13 @@ func BenchmarkRangeQuery(b *testing.B) {

b.ResetTimer()
b.ReportAllocs()

if *sixHourDatasetOnly {
if tc.test != sixHourDataset {
return
}
}

for i := 0; i < b.N; i++ {
qry, err := engine.NewRangeQuery(tc.test.Context(), tc.test.Queryable(), nil, tc.query, start, end, step)
testutil.Ok(b, err)
Expand All @@ -300,6 +312,12 @@ func BenchmarkRangeQuery(b *testing.B) {
b.ResetTimer()
b.ReportAllocs()

if *sixHourDatasetOnly {
if tc.test != sixHourDataset {
return
}
}

for i := 0; i < b.N; i++ {
newResult := executeRangeQuery(b, tc.query, tc.test, start, end, step)
testutil.Ok(b, newResult.Err)
Expand Down