Skip to content

Commit

Permalink
Update dependencies (#295)
Browse files Browse the repository at this point in the history
  • Loading branch information
sj14 authored Aug 25, 2024
1 parent ee146dc commit aca46e1
Show file tree
Hide file tree
Showing 12 changed files with 148 additions and 1,898 deletions.
19 changes: 10 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,14 @@ Usage | Description |
Usage | Description |
--------------------------|-----------------------------------------------|
`{{.Iter}}` | The iteration counter. Will return `1` when `\benchmark once`.
`{{call .Seed 42}}` | [godoc](https://golang.org/pkg/math/rand/#Seed) (`42` is an examplary seed)
`{{call .RandInt63}}` | [godoc](https://golang.org/pkg/math/rand/#Int63)
`{{call .RandInt63n 9999}}` | [godoc](https://golang.org/pkg/math/rand/#Int63n) (`9999` is an examplary upper limit)
`{{call .RandFloat32}}` | [godoc](https://golang.org/pkg/math/rand/#Float32)
`{{call .RandFloat64}}` | [godoc](https://golang.org/pkg/math/rand/#Float64)
`{{call .RandExpFloat64}}` | [godoc](https://golang.org/pkg/math/rand/#ExpFloat64)
`{{call .RandNormFloat64}}` | [godoc](https://golang.org/pkg/math/rand/#NormFloat64)
`{{call .RandInt64}}` | [godoc](https://pkg.go.dev/math/rand/v2#Int64)
`{{call .RandInt64N 9999}}` | [godoc](https://pkg.go.dev/math/rand/v2#Int64N) (`9999` is an examplary upper limit)
`{{call .RandUint64}}` | [godoc](https://pkg.go.dev/math/rand/v2#Uint64)
`{{call .RandUint64N 9999}}` | [godoc](https://pkg.go.dev/math/rand/v2#Uint64N) (`9999` is an examplary upper limit)
`{{call .RandFloat32}}` | [godoc](https://pkg.go.dev/math/rand/v2#Float32)
`{{call .RandFloat64}}` | [godoc](https://pkg.go.dev/math/rand/v2#Float64)
`{{call .RandExpFloat64}}` | [godoc](https://pkg.go.dev/math/rand/v2#ExpFloat64)
`{{call .RandNormFloat64}}` | [godoc](https://pkg.go.dev/math/rand/v2#NormFloat64)

### Example

Expand All @@ -135,13 +136,13 @@ CREATE TABLE dbbench_simple (id INT PRIMARY KEY, balance DECIMAL);

-- How long takes an insert and delete?
\benchmark loop \name single
INSERT INTO dbbench_simple (id, balance) VALUES({{.Iter}}, {{call .RandInt63}});
INSERT INTO dbbench_simple (id, balance) VALUES({{.Iter}}, {{call .RandInt64}});
DELETE FROM dbbench_simple WHERE id = {{.Iter}};

-- How long takes it in a single transaction?
\benchmark loop \name batch
BEGIN TRANSACTION;
INSERT INTO dbbench_simple (id, balance) VALUES({{.Iter}}, {{call .RandInt63}});
INSERT INTO dbbench_simple (id, balance) VALUES({{.Iter}}, {{call .RandInt64}});
DELETE FROM dbbench_simple WHERE id = {{.Iter}};
COMMIT;

Expand Down
16 changes: 9 additions & 7 deletions benchmark/benchmark.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package benchmark

import (
"log"
"math/rand"
"math/rand/v2"
"os"
"os/signal"
"strings"
Expand Down Expand Up @@ -172,18 +172,20 @@ func buildStmt(t *template.Template, i int) string {

data := struct {
Iter int
Seed func(int64)
RandInt63 func() int64
RandInt63n func(int64) int64
RandInt64 func() int64
RandInt64N func(int64) int64
RandUint64 func() uint64
RandUint64N func(uint64) uint64
RandFloat32 func() float32
RandFloat64 func() float64
RandExpFloat64 func() float64
RandNormFloat64 func() float64
}{
Iter: i,
Seed: rand.Seed,
RandInt63: rand.Int63,
RandInt63n: rand.Int63n,
RandInt64: rand.Int64,
RandInt64N: rand.Int64N,
RandUint64: rand.Uint64,
RandUint64N: rand.Uint64N,
RandFloat32: rand.Float32,
RandFloat64: rand.Float64,
RandExpFloat64: rand.ExpFloat64,
Expand Down
6 changes: 3 additions & 3 deletions benchmark/benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func TestLoop(t *testing.T) {
// arrange
bencher := &mockedBencher{}
bencher.On("Exec", mock.Anything)
tmpl := template.Must(template.New("test").Parse("{{.Iter}} {{call .RandInt63}}"))
tmpl := template.Must(template.New("test").Parse("{{.Iter}} {{call .RandInt64}}"))

executor := bencherExecutor{
result: Result{
Expand All @@ -94,7 +94,7 @@ func TestOnce(t *testing.T) {
// arrange
bencher := &mockedBencher{}
bencher.On("Exec", mock.Anything)
tmpl := template.Must(template.New("test").Parse("{{.Iter}} {{call .RandInt63}}"))
tmpl := template.Must(template.New("test").Parse("{{.Iter}} {{call .RandInt64}}"))

executor := bencherExecutor{
result: Result{
Expand All @@ -113,7 +113,7 @@ func TestResults(t *testing.T) {
// arrange
bencher := &mockedBencher{}
bencher.On("Exec", mock.Anything)
tmpl := template.Must(template.New("test").Parse("{{.Iter}} {{call .RandInt63}}"))
tmpl := template.Must(template.New("test").Parse("{{.Iter}} {{call .RandInt64}}"))

executor := bencherExecutor{
result: Result{
Expand Down
3 changes: 1 addition & 2 deletions cmd/dbbench/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package main
import (
"bytes"
"fmt"
"io/ioutil"
"log"
"os"
"os/signal"
Expand Down Expand Up @@ -184,7 +183,7 @@ func main() {

// If a script was specified, overwrite built-in benchmarks.
if *scriptname != "" {
dat, err := ioutil.ReadFile(*scriptname)
dat, err := os.ReadFile(*scriptname)
if err != nil {
log.Fatalf("failed to read file: %v", err)
}
Expand Down
4 changes: 2 additions & 2 deletions databases/cassandra.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ func NewCassandra(host string, port int, user, password string) *Cassandra {
// TODO: update is not like other db statements balance = balance + balance!
func (c *Cassandra) Benchmarks() []benchmark.Benchmark {
return []benchmark.Benchmark{
{Name: "inserts", Type: benchmark.TypeLoop, Stmt: "INSERT INTO dbbench.dbbench_simple (id, balance) VALUES({{.Iter}}, {{call .RandInt63}}) IF NOT EXISTS;"},
{Name: "inserts", Type: benchmark.TypeLoop, Stmt: "INSERT INTO dbbench.dbbench_simple (id, balance) VALUES({{.Iter}}, {{call .RandInt64}}) IF NOT EXISTS;"},
{Name: "selects", Type: benchmark.TypeLoop, Stmt: "SELECT * FROM dbbench.dbbench_simple WHERE id = {{.Iter}};"},
{Name: "updates", Type: benchmark.TypeLoop, Stmt: "UPDATE dbbench.dbbench_simple SET balance = {{call .RandInt63}} WHERE id = {{.Iter}} IF EXISTS;"},
{Name: "updates", Type: benchmark.TypeLoop, Stmt: "UPDATE dbbench.dbbench_simple SET balance = {{call .RandInt64}} WHERE id = {{.Iter}} IF EXISTS;"},
{Name: "deletes", Type: benchmark.TypeLoop, Stmt: "DELETE FROM dbbench.dbbench_simple WHERE id = {{.Iter}} IF EXISTS;"},
}
}
Expand Down
8 changes: 4 additions & 4 deletions databases/cockroach.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ func NewCockroach(host string, port int, user, password string, maxOpenConns int
// Benchmarks returns the individual benchmark functions for the cockroach db.
func (p *Cockroach) Benchmarks() []benchmark.Benchmark {
return []benchmark.Benchmark{
{Name: "inserts", Type: benchmark.TypeLoop, Stmt: "INSERT INTO dbbench.simple (id, balance) VALUES( {{.Iter}}, {{call .RandInt63}});"},
{Name: "inserts", Type: benchmark.TypeLoop, Stmt: "INSERT INTO dbbench.simple (id, balance) VALUES( {{.Iter}}, {{call .RandInt64}});"},
{Name: "selects", Type: benchmark.TypeLoop, Stmt: "SELECT * FROM dbbench.simple WHERE id = {{.Iter}};"},
{Name: "updates", Type: benchmark.TypeLoop, Stmt: "UPDATE dbbench.simple SET balance = {{call .RandInt63}} WHERE id = {{.Iter}};"},
{Name: "updates", Type: benchmark.TypeLoop, Stmt: "UPDATE dbbench.simple SET balance = {{call .RandInt64}} WHERE id = {{.Iter}};"},
{Name: "deletes", Type: benchmark.TypeLoop, Stmt: "DELETE FROM dbbench.simple WHERE id = {{.Iter}};"},
// {"relation_insert0", benchmark.TypeLoop, "INSERT INTO dbbench.relational_one (oid, balance_one) VALUES( {{.Iter}}, {{call .RandInt63}});"},
// {"relation_insert1", benchmark.TypeLoop, "INSERT INTO dbbench.relational_two (relation, balance_two) VALUES( {{.Iter}}, {{call .RandInt63}});"},
// {"relation_insert0", benchmark.TypeLoop, "INSERT INTO dbbench.relational_one (oid, balance_one) VALUES( {{.Iter}}, {{call .RandInt64}});"},
// {"relation_insert1", benchmark.TypeLoop, "INSERT INTO dbbench.relational_two (relation, balance_two) VALUES( {{.Iter}}, {{call .RandInt64}});"},
// {"relation_select", benchmark.TypeLoop, "SELECT * FROM dbbench.relational_two INNER JOIN dbbench.relational_one ON relational_one.oid = relational_two.relation WHERE relation = {{.Iter}};"},
// {"relation_delete1", benchmark.TypeLoop, "DELETE FROM dbbench.relational_two WHERE relation = {{.Iter}};"},
// {"relation_delete0", benchmark.TypeLoop, "DELETE FROM dbbench.relational_one WHERE oid = {{.Iter}};"},
Expand Down
8 changes: 4 additions & 4 deletions databases/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ func NewMySQL(host string, port int, user, password string, maxOpenConns int) *M
// Benchmarks returns the individual benchmark functions for the mysql db.
func (m *Mysql) Benchmarks() []benchmark.Benchmark {
return []benchmark.Benchmark{
{Name: "inserts", Type: benchmark.TypeLoop, Stmt: "INSERT INTO dbbench.simple (id, balance) VALUES( {{.Iter}}, {{call .RandInt63n 9999999999}});"},
{Name: "inserts", Type: benchmark.TypeLoop, Stmt: "INSERT INTO dbbench.simple (id, balance) VALUES( {{.Iter}}, {{call .RandInt64N 9999999999}});"},
{Name: "selects", Type: benchmark.TypeLoop, Stmt: "SELECT * FROM dbbench.simple WHERE id = {{.Iter}};"},
{Name: "updates", Type: benchmark.TypeLoop, Stmt: "UPDATE dbbench.simple SET balance = {{call .RandInt63n 9999999999}} WHERE id = {{.Iter}};"},
{Name: "updates", Type: benchmark.TypeLoop, Stmt: "UPDATE dbbench.simple SET balance = {{call .RandInt64N 9999999999}} WHERE id = {{.Iter}};"},
{Name: "deletes", Type: benchmark.TypeLoop, Stmt: "DELETE FROM dbbench.simple WHERE id = {{.Iter}};"},
// {"relation_insert0", benchmark.TypeLoop, "INSERT INTO dbbench.relational_one (oid, balance_one) VALUES( {{.Iter}}, {{call .RandInt63n 9999999999}});"},
// {"relation_insert1", benchmark.TypeLoop, "INSERT INTO dbbench.relational_two (relation, balance_two) VALUES( {{.Iter}}, {{call .RandInt63n 9999999999}});"},
// {"relation_insert0", benchmark.TypeLoop, "INSERT INTO dbbench.relational_one (oid, balance_one) VALUES( {{.Iter}}, {{call .RandInt64N 9999999999}});"},
// {"relation_insert1", benchmark.TypeLoop, "INSERT INTO dbbench.relational_two (relation, balance_two) VALUES( {{.Iter}}, {{call .RandInt64N 9999999999}});"},
// {"relation_select", benchmark.TypeLoop, "SELECT * FROM dbbench.relational_two INNER JOIN dbbench.relational_one ON relational_one.oid = relational_two.relation WHERE relation = {{.Iter}};"},
// {"relation_delete1", benchmark.TypeLoop, "DELETE FROM dbbench.relational_two WHERE relation = {{.Iter}};"},
// {"relation_delete0", benchmark.TypeLoop, "DELETE FROM dbbench.relational_one WHERE oid = {{.Iter}};"},
Expand Down
8 changes: 4 additions & 4 deletions databases/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ func NewPostgres(host string, port int, user, password string, maxOpenConns int)
// Benchmarks returns the individual benchmark statements for the postgres db.
func (p *Postgres) Benchmarks() []benchmark.Benchmark {
return []benchmark.Benchmark{
{Name: "inserts", Type: benchmark.TypeLoop, Stmt: "INSERT INTO dbbench.simple (id, balance) VALUES( {{.Iter}}, {{call .RandInt63}});"},
{Name: "inserts", Type: benchmark.TypeLoop, Stmt: "INSERT INTO dbbench.simple (id, balance) VALUES( {{.Iter}}, {{call .RandInt64}});"},
{Name: "selects", Type: benchmark.TypeLoop, Stmt: "SELECT * FROM dbbench.simple WHERE id = {{.Iter}};"},
{Name: "updates", Type: benchmark.TypeLoop, Stmt: "UPDATE dbbench.simple SET balance = {{call .RandInt63}} WHERE id = {{.Iter}};"},
{Name: "updates", Type: benchmark.TypeLoop, Stmt: "UPDATE dbbench.simple SET balance = {{call .RandInt64}} WHERE id = {{.Iter}};"},
{Name: "deletes", Type: benchmark.TypeLoop, Stmt: "DELETE FROM dbbench.simple WHERE id = {{.Iter}};"},
// {"relation_insert0", benchmark.TypeLoop, "INSERT INTO dbbench.relational_one (oid, balance_one) VALUES( {{.Iter}}, {{call .RandInt63}});"},
// {"relation_insert1", benchmark.TypeLoop, "INSERT INTO dbbench.relational_two (relation, balance_two) VALUES( {{.Iter}}, {{call .RandInt63}});"},
// {"relation_insert0", benchmark.TypeLoop, "INSERT INTO dbbench.relational_one (oid, balance_one) VALUES( {{.Iter}}, {{call .RandInt64}});"},
// {"relation_insert1", benchmark.TypeLoop, "INSERT INTO dbbench.relational_two (relation, balance_two) VALUES( {{.Iter}}, {{call .RandInt64}});"},
// {"relation_select", benchmark.TypeLoop, "SELECT * FROM dbbench.relational_two INNER JOIN dbbench.relational_one ON relational_one.oid = relational_two.relation WHERE relation = {{.Iter}};"},
// {"relation_delete1", benchmark.TypeLoop, "DELETE FROM dbbench.relational_two WHERE relation = {{.Iter}};"},
// {"relation_delete0", benchmark.TypeLoop, "DELETE FROM dbbench.relational_one WHERE oid = {{.Iter}};"},
Expand Down
8 changes: 4 additions & 4 deletions databases/sqlite.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ func NewSQLite(path string) *SQLite {
// Benchmarks returns the individual benchmark statements for sqlite.
func (m *SQLite) Benchmarks() []benchmark.Benchmark {
return []benchmark.Benchmark{
{Name: "inserts", Type: benchmark.TypeLoop, Stmt: "INSERT INTO dbbench_simple (id, balance) VALUES( {{.Iter}}, {{call .RandInt63}});"},
{Name: "inserts", Type: benchmark.TypeLoop, Stmt: "INSERT INTO dbbench_simple (id, balance) VALUES( {{.Iter}}, {{call .RandInt64}});"},
{Name: "selects", Type: benchmark.TypeLoop, Stmt: "SELECT * FROM dbbench_simple WHERE id = {{.Iter}};"},
{Name: "updates", Type: benchmark.TypeLoop, Stmt: "UPDATE dbbench_simple SET balance = {{call .RandInt63}} WHERE id = {{.Iter}};"},
{Name: "updates", Type: benchmark.TypeLoop, Stmt: "UPDATE dbbench_simple SET balance = {{call .RandInt64}} WHERE id = {{.Iter}};"},
{Name: "deletes", Type: benchmark.TypeLoop, Stmt: "DELETE FROM dbbench_simple WHERE id = {{.Iter}};"},
// {"relation_insert0", benchmark.TypeLoop, "INSERT INTO dbbench_relational_one (oid, balance_one) VALUES( {{.Iter}}, {{call .RandInt63}});"},
// {"relation_insert1", benchmark.TypeLoop, "INSERT INTO dbbench_relational_two (relation, balance_two) VALUES( {{.Iter}}, {{call .RandInt63}});"},
// {"relation_insert0", benchmark.TypeLoop, "INSERT INTO dbbench_relational_one (oid, balance_one) VALUES( {{.Iter}}, {{call .RandInt64}});"},
// {"relation_insert1", benchmark.TypeLoop, "INSERT INTO dbbench_relational_two (relation, balance_two) VALUES( {{.Iter}}, {{call .RandInt64}});"},
// {"relation_select", benchmark.TypeLoop, "SELECT * FROM dbbench_relational_two INNER JOIN dbbench_relational_one ON dbbench_relational_one.oid = relation WHERE relation = {{.Iter}};"},
// {"relation_delete1", benchmark.TypeLoop, "DELETE FROM dbbench_relational_two WHERE relation = {{.Iter}};"},
// {"relation_delete0", benchmark.TypeLoop, "DELETE FROM dbbench_relational_one WHERE oid = {{.Iter}};"},
Expand Down
57 changes: 54 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,15 +1,66 @@
module github.com/sj14/dbbench

go 1.14
go 1.23.0

require (
cloud.google.com/go/spanner v1.66.0
cloud.google.com/go/spanner v1.67.0
github.com/denisenkom/go-mssqldb v0.12.3
github.com/go-sql-driver/mysql v1.8.1
github.com/gocql/gocql v1.6.0
github.com/lib/pq v1.10.9
github.com/mattn/go-sqlite3 v2.0.3+incompatible
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.9.0
google.golang.org/api v0.192.0
google.golang.org/api v0.194.0
)

require (
cel.dev/expr v0.16.0 // indirect
cloud.google.com/go v0.115.1 // indirect
cloud.google.com/go/auth v0.9.1 // indirect
cloud.google.com/go/auth/oauth2adapt v0.2.4 // indirect
cloud.google.com/go/compute/metadata v0.5.0 // indirect
filippo.io/edwards25519 v1.1.0 // indirect
github.com/GoogleCloudPlatform/grpc-gcp-go/grpcgcp v1.5.0 // indirect
github.com/census-instrumentation/opencensus-proto v0.4.1 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/cncf/xds/go v0.0.0-20240822171458-6449f94b4d59 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/envoyproxy/go-control-plane v0.13.0 // indirect
github.com/envoyproxy/protoc-gen-validate v1.1.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 // indirect
github.com/golang-sql/sqlexp v0.1.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/s2a-go v0.1.8 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
github.com/googleapis/gax-go/v2 v2.13.0 // indirect
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed // indirect
github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rogpeppe/go-internal v1.12.0 // indirect
github.com/stretchr/objx v0.5.2 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.54.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0 // indirect
go.opentelemetry.io/otel v1.29.0 // indirect
go.opentelemetry.io/otel/metric v1.29.0 // indirect
go.opentelemetry.io/otel/trace v1.29.0 // indirect
golang.org/x/crypto v0.26.0 // indirect
golang.org/x/net v0.28.0 // indirect
golang.org/x/oauth2 v0.22.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.24.0 // indirect
golang.org/x/text v0.17.0 // indirect
golang.org/x/time v0.6.0 // indirect
golang.org/x/xerrors v0.0.0-20240716161551-93cc26a95ae9 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240823204242-4ba0660f739c // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240823204242-4ba0660f739c // indirect
google.golang.org/grpc v1.65.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit aca46e1

Please sign in to comment.