Go vs CGo benchmarks refactored (not TPCH)

This commit is contained in:
glebarez
2021-12-16 12:50:41 +00:00
parent 019ed373da
commit abe4fa449b
15 changed files with 1473 additions and 189 deletions

45
benchmark/bench_test.go Normal file
View File

@@ -0,0 +1,45 @@
// Copyright 2021 The Sqlite Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// this file allows to run benchmarks via go test
package benchmark
import (
"math"
"testing"
)
func BenchmarkSelect(b *testing.B) {
doBenchmarkOfNrows(b, benchmarkSelect)
}
// https://gitlab.com/cznic/sqlite/-/issues/39
func BenchmarkInsert(b *testing.B) {
doBenchmarkOfNrows(b, benchmarkInsert)
}
func doBenchmarkOfNrows(b *testing.B, benchFunc bechmarkOfNRows) {
for _, isMemoryDB := range inMemory { // in-memory: on/off
for _, e := range rowCountsE { // number of rows in table
for _, driverName := range drivers { // drivers
// create new DB
db := createDB(b, isMemoryDB, driverName)
// run benchmark
b.Run(
makeName(isMemoryDB, driverName, e),
func(b *testing.B) {
benchFunc(b, db, int(math.Pow10(e)))
},
)
// close DB
if err := db.Close(); err != nil {
b.Fatal(err)
}
}
}
}
}