aboutsummaryrefslogtreecommitdiff
path: root/benchmark
diff options
context:
space:
mode:
authorStefan Majewsky <majewsky@gmx.net>2026-04-18 17:10:34 +0200
committerStefan Majewsky <majewsky@gmx.net>2026-04-18 17:10:34 +0200
commitf8904431aa09796dab3c0bd159af74f8da4a153e (patch)
treebaee66ed5e4a262d60abac4a72d141b6a621c922 /benchmark
parent5afee58195a779e3c00432b1ecb9cce6c30b11d2 (diff)
downloadgo-oblast-f8904431aa09796dab3c0bd159af74f8da4a153e.tar.gz
add type PreparedSelectQuery
Diffstat (limited to 'benchmark')
-rw-r--r--benchmark/benchmark_test.go8
1 files changed, 5 insertions, 3 deletions
diff --git a/benchmark/benchmark_test.go b/benchmark/benchmark_test.go
index 2b0545a..ada238e 100644
--- a/benchmark/benchmark_test.go
+++ b/benchmark/benchmark_test.go
@@ -23,7 +23,7 @@ import (
// This is not a real benchmark (obviously).
// Its purpose is to be the first line that is printed, while having one of the longest names,
// so that all other results are aligned with it and the table looks nice.
-func BenchmarkHeadingHeadingHeadingHeadingHeadingHeading(b *testing.B) {
+func BenchmarkHeadingHeadingHeadingHeadingHeadingHeadingHeading(b *testing.B) {
for b.Loop() {
time.Sleep(time.Microsecond)
}
@@ -88,6 +88,7 @@ func BenchmarkSelectMany(b *testing.B) {
gormDB := must.Return(gorm.Open(sqlite.Open(dsn), &gorm.Config{}))(b)
partialQuery := `id < ` + strconv.Itoa(batchSize)
query := `SELECT * FROM entries WHERE ` + partialQuery
+ precomputedQuery := store.MustPrepareSelectQueryWhere(partialQuery)
selectWithOblast := func(b *testing.B) {
records := must.Return(store.Select(db, query))(b)
@@ -95,7 +96,7 @@ func BenchmarkSelectMany(b *testing.B) {
}
selectWithOblastWhere := func(b *testing.B) {
- records := must.Return(store.SelectWhere(db, partialQuery))(b)
+ records := must.Return(precomputedQuery.Select(db))(b)
assert.Equal(b, len(records), batchSize)
}
@@ -181,6 +182,7 @@ func BenchmarkSelectOne(b *testing.B) {
gormDB := must.Return(gorm.Open(sqlite.Open(dsn), &gorm.Config{}))(b)
partialQuery := `id = ` + strconv.Itoa(recordID)
query := `SELECT * FROM entries WHERE ` + partialQuery
+ precomputedQuery := store.MustPrepareSelectQueryWhere(partialQuery)
selectWithOblast := func(b *testing.B) {
r := must.Return(store.SelectOne(db, query))(b)
@@ -188,7 +190,7 @@ func BenchmarkSelectOne(b *testing.B) {
}
selectWithOblastWhere := func(b *testing.B) {
- r := must.Return(store.SelectOneWhere(db, partialQuery))(b)
+ r := must.Return(precomputedQuery.SelectOne(db))(b)
assert.Equal(b, r.ID, recordID)
}