From fff3c6e615f26e98280f785ec3ef95deb0753876 Mon Sep 17 00:00:00 2001 From: Tim Voronov Date: Fri, 8 Nov 2024 15:10:25 -0500 Subject: [PATCH] Updates some benchmarks --- pkg/compiler/compiler_array_test.go | 50 +++++++++++++++---- .../compiler_collect_aggregate_test.go | 15 ++++-- pkg/compiler/compiler_collect_count_test.go | 5 +- pkg/compiler/compiler_for_ternary_test.go | 2 + 4 files changed, 58 insertions(+), 14 deletions(-) diff --git a/pkg/compiler/compiler_array_test.go b/pkg/compiler/compiler_array_test.go index 96921ea7..c7bcedfe 100644 --- a/pkg/compiler/compiler_array_test.go +++ b/pkg/compiler/compiler_array_test.go @@ -337,8 +337,11 @@ func BenchmarkArrayOperatorALL(b *testing.B) { RETURN [1,2,3] ALL IN [1,2,3] `) + ctx := context.Background() + b.ResetTimer() + for n := 0; n < b.N; n++ { - p.Run(context.Background()) + p.Run(ctx) } } @@ -347,8 +350,11 @@ func BenchmarkArrayOperatorALL2(b *testing.B) { RETURN [1,2,4] ALL IN [1,2,3] `) + ctx := context.Background() + b.ResetTimer() + for n := 0; n < b.N; n++ { - p.Run(context.Background()) + p.Run(ctx) } } @@ -357,8 +363,11 @@ func BenchmarkArrayOperatorANY(b *testing.B) { RETURN [1,2,3] ANY IN [1,2,3] `) + ctx := context.Background() + b.ResetTimer() + for n := 0; n < b.N; n++ { - p.Run(context.Background()) + p.Run(ctx) } } @@ -367,8 +376,11 @@ func BenchmarkArrayOperatorANY2(b *testing.B) { RETURN [4,5,6] ANY IN [1,2,3] `) + ctx := context.Background() + b.ResetTimer() + for n := 0; n < b.N; n++ { - p.Run(context.Background()) + p.Run(ctx) } } @@ -377,8 +389,11 @@ func BenchmarkArrayOperatorANY3(b *testing.B) { RETURN [4,5,6] ANY NOT IN [1,2,3] `) + ctx := context.Background() + b.ResetTimer() + for n := 0; n < b.N; n++ { - p.Run(context.Background()) + p.Run(ctx) } } @@ -387,8 +402,11 @@ func BenchmarkArrayOperatorANY4(b *testing.B) { RETURN [1,2,3 ] ANY == 2 `) + ctx := context.Background() + b.ResetTimer() + for n := 0; n < b.N; n++ { - p.Run(context.Background()) + p.Run(ctx) } } @@ -397,8 +415,11 @@ func BenchmarkArrayOperatorNONE(b *testing.B) { RETURN [1,2,3] NONE IN [1,2,3] `) + ctx := context.Background() + b.ResetTimer() + for n := 0; n < b.N; n++ { - p.Run(context.Background()) + p.Run(ctx) } } @@ -407,8 +428,11 @@ func BenchmarkArrayOperatorNONE2(b *testing.B) { RETURN [4,5,6] NONE IN [1,2,3] `) + ctx := context.Background() + b.ResetTimer() + for n := 0; n < b.N; n++ { - p.Run(context.Background()) + p.Run(ctx) } } @@ -417,8 +441,11 @@ func BenchmarkArrayOperatorNONE3(b *testing.B) { RETURN [4,5,6] NONE NOT IN [1,2,3] `) + ctx := context.Background() + b.ResetTimer() + for n := 0; n < b.N; n++ { - p.Run(context.Background()) + p.Run(ctx) } } @@ -427,7 +454,10 @@ func BenchmarkArrayOperatorNONE4(b *testing.B) { RETURN [1,2,3] NONE < 99 `) + ctx := context.Background() + b.ResetTimer() + for n := 0; n < b.N; n++ { - p.Run(context.Background()) + p.Run(ctx) } } diff --git a/pkg/compiler/compiler_collect_aggregate_test.go b/pkg/compiler/compiler_collect_aggregate_test.go index 2616db03..6c05e085 100644 --- a/pkg/compiler/compiler_collect_aggregate_test.go +++ b/pkg/compiler/compiler_collect_aggregate_test.go @@ -212,8 +212,11 @@ func BenchmarkAggregate(b *testing.B) { } `) + ctx := context.Background() + b.ResetTimer() + for n := 0; n < b.N; n++ { - p.Run(context.Background()) + p.Run(ctx) } } @@ -256,8 +259,11 @@ func BenchmarkAggregate2(b *testing.B) { RETURN ages `) + ctx := context.Background() + b.ResetTimer() + for n := 0; n < b.N; n++ { - p.Run(context.Background()) + p.Run(ctx) } } @@ -305,7 +311,10 @@ func BenchmarkAggregate3(b *testing.B) { } `) + ctx := context.Background() + b.ResetTimer() + for n := 0; n < b.N; n++ { - p.Run(context.Background()) + p.Run(ctx) } } diff --git a/pkg/compiler/compiler_collect_count_test.go b/pkg/compiler/compiler_collect_count_test.go index 20eb7051..0d39e0dd 100644 --- a/pkg/compiler/compiler_collect_count_test.go +++ b/pkg/compiler/compiler_collect_count_test.go @@ -101,7 +101,10 @@ func BenchmarkCollectCount(b *testing.B) { RETURN c `) + ctx := context.Background() + b.ResetTimer() + for n := 0; n < b.N; n++ { - p.Run(context.Background()) + p.Run(ctx) } } diff --git a/pkg/compiler/compiler_for_ternary_test.go b/pkg/compiler/compiler_for_ternary_test.go index cbc0ab18..b6dcae05 100644 --- a/pkg/compiler/compiler_for_ternary_test.go +++ b/pkg/compiler/compiler_for_ternary_test.go @@ -153,6 +153,8 @@ func BenchmarkForTernary(b *testing.B) { RETURN foo ? TRUE : (FOR i IN 1..5 RETURN i*2) `) + b.ResetTimer() + for n := 0; n < b.N; n++ { p.Run(context.Background()) }