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

Add new benchmarks #4

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ models
boilbench
benches
*.test
sqlboiler.toml
/graphs
/graph_data
/.idea
sqlc/generated
/go_pg/sqlcgenerated/
/go_pg/boilgenerated/
24 changes: 20 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,30 @@

### Requirements

These tests require go1.7
These tests require go1.11 (go1.11 has support for go modules that are used here, go1.14 is recommended as current benchmarks were run using go1.14)
and installed docker

### Instructions

1. Clone this repository.
1. Create a `sqlboiler.toml` in the root directory.
1. Run `./initdb.sh` to create your db and generate your models folder.
1. Run the benches: `go test -bench . -benchmem`
1. Update a `sqlboiler.toml` in the root directory if needed.
1. Modify port `initdb.sh` and run `./initdb.sh` to create your db and generate your models folder.
1. Run the benches against mocked (mimic) driver: `go test -bench . -benchmem`

Previous results can be found in `./results/mocked_driver.txt`

### go-pg benchmarks
As [go-pg](https://github.com/go-pg/pg) is not implementing `database/sql`,
to compare `database/sql` based implementations benchmarks should be run against real db

in `/go_pg` directory you will find files related to benchmarks comparison of [sqlc](https://github.com/kyleconroy/sqlc), [sqlboiler](https://github.com/volatiletech/sqlboiler) against go-pg both for CockroachDB and PostgresDB (all using docker), benchmarks are using same approach as described in [go-pg](https://github.com/go-pg/pg/blob/v10.0.0-beta.1/bench_test.go) repository

1. Run benchmark against CockroachDB (it will also set up DB, generate all needed files): `./go_pg/prepare_and_run_cockroach.sh`
Previous results can be found in `./results/go_pg_cockroach.txt`
1. Run benchmark against PostgresDB (it will also set up DB, generate all needed files): `./go_pg/prepare_and_run_postgres.sh`
Previous results can be found in `./results/go_pg_postgres.txt`

Inside each correspondent script variable `port` is defined. Override it if standard DB ports are already occupied on your machine.

**Note**: There are some ruby and python scripts for generating graphs from
many runs of these benchmarks. They can be used to help update the sqlboiler
Expand Down
26 changes: 25 additions & 1 deletion delete_test.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
package main

import (
"context"
"database/sql"
"testing"

"xorm.io/xorm"
"github.com/jinzhu/gorm"
"github.com/volatiletech/boilbench/gorms"
"github.com/volatiletech/boilbench/gorps"
"github.com/volatiletech/boilbench/kallaxes"
"github.com/volatiletech/boilbench/mimic"
"github.com/volatiletech/boilbench/models"
sqlc "github.com/volatiletech/boilbench/sqlc/generated"
"github.com/volatiletech/boilbench/xorms"
"gopkg.in/gorp.v1"
"xorm.io/xorm"
)

func BenchmarkGORMDelete(b *testing.B) {
Expand Down Expand Up @@ -142,3 +144,25 @@ func BenchmarkBoilDelete(b *testing.B) {
}
})
}

func BenchmarkSqlcDelete(b *testing.B) {
exec := jetExec()
exec.NumInput = -1
mimic.NewResult(exec)

db, err := sql.Open("mimic", "")
if err != nil {
panic(err)
}

dbc := sqlc.New(db)

b.Run("sqlc", func(b *testing.B) {
for i := 0; i < b.N; i++ {
err := dbc.DeleteJet(context.Background(), 1)
if err != nil {
b.Fatal(err)
}
}
})
}
35 changes: 35 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
module github.com/volatiletech/boilbench

go 1.14

require (
github.com/DATA-DOG/go-sqlmock v1.4.1 // indirect
github.com/Masterminds/squirrel v1.4.0 // indirect
github.com/friendsofgo/errors v0.9.2
github.com/glerchundi/sqlboiler-crdb v0.0.0-20200507094411-785f9766376c
github.com/go-pg/pg/v10 v10.0.0-beta.1
github.com/go-sql-driver/mysql v1.5.1-0.20200311113236-681ffa848bae
github.com/gofrs/uuid v3.3.0+incompatible // indirect
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect
github.com/jcmturner/gokrb5/v8 v8.3.0 // indirect
github.com/jinzhu/gorm v1.9.12
github.com/jmoiron/sqlx v1.2.0
github.com/json-iterator/go v1.1.9 // indirect
github.com/kyleconroy/sqlc v1.3.0
github.com/lib/pq v1.6.0
github.com/mitchellh/mapstructure v1.2.2 // indirect
github.com/pkg/errors v0.9.1
github.com/satori/go.uuid v1.2.0 // indirect
github.com/spf13/cobra v1.0.0 // indirect
github.com/spf13/viper v1.7.0
github.com/volatiletech/inflect v0.0.1 // indirect
github.com/volatiletech/null v8.0.0+incompatible
github.com/volatiletech/sqlboiler v3.7.1+incompatible
golang.org/x/crypto v0.0.0-20200604202706-70a84ac30bf9 // indirect
golang.org/x/net v0.0.0-20200602114024-627f9648deb9 // indirect
golang.org/x/tools v0.0.0-20200329025819-fd4102a86c65 // indirect
gopkg.in/gorp.v1 v1.7.2
gopkg.in/src-d/go-kallax.v1 v1.3.5
xorm.io/core v0.7.3
xorm.io/xorm v1.0.1
)
Loading