diff --git a/.github/run_benchmarks_actions.sh b/.github/run_benchmarks_actions.sh index 89a55bb..f88af3f 100755 --- a/.github/run_benchmarks_actions.sh +++ b/.github/run_benchmarks_actions.sh @@ -1,23 +1,16 @@ #!/usr/bin/env bash # Prototype benchmark results -proto=$(cat data/results.md.proto) - -# Benchmark operations -operations=("with-no-flag|1" "multi-5|5" "multi-10|10" "multi-20|20") +proto=$(cat .github/data/results.md.proto) # Build benchmarker go build main.go -for operation in "${operations[@]}"; do - IFS="|"; read -a operation <<< "$operation" - - # Apply output to template - logs=$(./main -source="host=localhost user=postgres password=postgres dbname=test sslmode=disable" -multi=${operation[1]} -debug=false) - escaped=$(echo "${logs}" | sed '$!s@$@\\@g') +# Apply output to template +logs=$(./main -source="host=localhost user=postgres password=postgres dbname=test sslmode=disable" -debug=false) +escaped=$(echo "${logs}" | sed '$!s@$@\\@g') - proto=$(sed "s|@(${operation[0]})|${escaped}|g" <<< $proto) -done +proto=$(sed "s|@(benchmark-results)|${escaped}|g" <<< $proto) # Print final results & delete benchmarker rm main diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 9fc05f6..2a44522 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -21,4 +21,4 @@ jobs: - name: Build Benchmarker run: go build main.go - name: Run Benchmarker - run: ./main -source="host=localhost user=postgres password=postgres dbname=test sslmode=disable" -orm=all -multi=1 -debug=false \ No newline at end of file + run: ./main -source="host=localhost user=postgres password=postgres dbname=test sslmode=disable" -orm=all -debug=false \ No newline at end of file diff --git a/bench/beego.go b/bench/beego.go index 0e7a3b8..1704f40 100644 --- a/bench/beego.go +++ b/bench/beego.go @@ -4,13 +4,11 @@ import ( "fmt" "github.com/astaxie/beego/orm" "github.com/efectn/go-orm-benchmarks/helper" - "sync" "testing" ) type Beego struct { helper.ORMInterface - mu sync.Mutex conn orm.Ormer } diff --git a/bench/bun.go b/bench/bun.go index d531a6b..79c5a56 100644 --- a/bench/bun.go +++ b/bench/bun.go @@ -3,7 +3,6 @@ package bench import ( "database/sql" "github.com/efectn/go-orm-benchmarks/helper" - "sync" "testing" bundb "github.com/uptrace/bun" @@ -13,7 +12,6 @@ import ( type Bun struct { helper.ORMInterface - mu sync.Mutex conn *bundb.DB } diff --git a/bench/dbr.go b/bench/dbr.go index da090e7..ecb33e4 100644 --- a/bench/dbr.go +++ b/bench/dbr.go @@ -2,7 +2,6 @@ package bench import ( "github.com/efectn/go-orm-benchmarks/helper" - "sync" "testing" dbrware "github.com/gocraft/dbr/v2" @@ -13,7 +12,6 @@ var columns = []string{"name", "title", "fax", "web", "age", "right", "counter"} type Dbr struct { helper.ORMInterface - mu sync.Mutex conn *dbrware.Session } diff --git a/bench/ent.go b/bench/ent.go index a9e112c..3cc38d8 100644 --- a/bench/ent.go +++ b/bench/ent.go @@ -3,7 +3,6 @@ package bench import ( "database/sql" "github.com/efectn/go-orm-benchmarks/helper" - "sync" "testing" "entgo.io/ent/dialect" @@ -15,7 +14,6 @@ import ( type Ent struct { helper.ORMInterface - mu sync.Mutex conn *entdb.Client dbEnt *sql.DB } @@ -102,7 +100,7 @@ func (ent *Ent) InsertMulti(b *testing.B) { func (ent *Ent) Update(b *testing.B) { m := NewModelAlt() - _, err := ent.conn.Model.Create(). + created, err := ent.conn.Model.Create(). SetName(m.Name). SetTitle(m.Title). SetFax(m.Fax). @@ -114,6 +112,7 @@ func (ent *Ent) Update(b *testing.B) { if err != nil { helper.SetError(b, ent.Name(), "Update", err.Error()) } + m.Id = created.ID b.ReportAllocs() b.ResetTimer() @@ -138,7 +137,7 @@ func (ent *Ent) Update(b *testing.B) { func (ent *Ent) Read(b *testing.B) { m := NewModelAlt() - _, err := ent.conn.Model.Create(). + created, err := ent.conn.Model.Create(). SetName(m.Name). SetTitle(m.Title). SetFax(m.Fax). @@ -150,12 +149,13 @@ func (ent *Ent) Read(b *testing.B) { if err != nil { helper.SetError(b, ent.Name(), "Read", err.Error()) } + m.Id = created.ID b.ReportAllocs() b.ResetTimer() for i := 0; i < b.N; i++ { - _, err := ent.conn.Model.Query().Where(model.IDEQ(1)).First(ctx) + _, err := ent.conn.Model.Query().Where(model.IDEQ(m.Id)).First(ctx) if err != nil { helper.SetError(b, ent.Name(), "Read", err.Error()) } diff --git a/bench/godb.go b/bench/godb.go index b62aee2..1a884c5 100644 --- a/bench/godb.go +++ b/bench/godb.go @@ -5,13 +5,11 @@ import ( _ "github.com/jackc/pgx/v4/stdlib" godbware "github.com/samonzeweb/godb" "github.com/samonzeweb/godb/adapters/postgresql" - "sync" "testing" ) type Godb struct { helper.ORMInterface - mu sync.Mutex conn *godbware.DB } diff --git a/bench/gorm.go b/bench/gorm.go index 96a4dfd..ffe74fd 100644 --- a/bench/gorm.go +++ b/bench/gorm.go @@ -5,13 +5,11 @@ import ( "gorm.io/driver/postgres" gormdb "gorm.io/gorm" "gorm.io/gorm/logger" - "sync" "testing" ) type Gorm struct { helper.ORMInterface - mu sync.Mutex conn *gormdb.DB } diff --git a/bench/gorm_prep.go b/bench/gorm_prep.go index 3559aee..f0e0731 100644 --- a/bench/gorm_prep.go +++ b/bench/gorm_prep.go @@ -5,13 +5,11 @@ import ( "gorm.io/driver/postgres" gormdb "gorm.io/gorm" "gorm.io/gorm/logger" - "sync" "testing" ) type GormPrep struct { helper.ORMInterface - mu sync.Mutex conn *gormdb.DB } diff --git a/bench/gorp.go b/bench/gorp.go index c604673..c3db1f0 100644 --- a/bench/gorp.go +++ b/bench/gorp.go @@ -3,7 +3,6 @@ package bench import ( "database/sql" "github.com/efectn/go-orm-benchmarks/helper" - "sync" "testing" _ "github.com/jackc/pgx/v4/stdlib" @@ -13,7 +12,6 @@ import ( type Gorp struct { helper.ORMInterface - mu sync.Mutex conn *gorpware.DbMap } diff --git a/bench/pg.go b/bench/pg.go index f6df2cc..810bf20 100644 --- a/bench/pg.go +++ b/bench/pg.go @@ -3,13 +3,11 @@ package bench import ( "github.com/efectn/go-orm-benchmarks/helper" pgdb "github.com/go-pg/pg/v10" - "sync" "testing" ) type Pg struct { helper.ORMInterface - mu sync.Mutex conn *pgdb.DB } diff --git a/bench/pgx.go b/bench/pgx.go index c9b11be..e328f4c 100644 --- a/bench/pgx.go +++ b/bench/pgx.go @@ -3,13 +3,11 @@ package bench import ( "github.com/efectn/go-orm-benchmarks/helper" pgxdb "github.com/jackc/pgx/v4" - "sync" "testing" ) type Pgx struct { helper.ORMInterface - mu sync.Mutex conn *pgxdb.Conn } diff --git a/bench/pgx_pool.go b/bench/pgx_pool.go index b189e74..f3db7b1 100644 --- a/bench/pgx_pool.go +++ b/bench/pgx_pool.go @@ -4,13 +4,11 @@ import ( "github.com/efectn/go-orm-benchmarks/helper" pgxdb "github.com/jackc/pgx/v4" "github.com/jackc/pgx/v4/pgxpool" - "sync" "testing" ) type PgxPool struct { helper.ORMInterface - mu sync.Mutex conn *pgxpool.Pool } diff --git a/bench/pop.go b/bench/pop.go index 0287840..9f98366 100644 --- a/bench/pop.go +++ b/bench/pop.go @@ -2,7 +2,6 @@ package bench import ( "github.com/efectn/go-orm-benchmarks/helper" - "sync" "testing" popware "github.com/gobuffalo/pop/v6" @@ -11,7 +10,6 @@ import ( type Pop struct { helper.ORMInterface - mu sync.Mutex conn *popware.Connection } diff --git a/bench/raw.go b/bench/raw.go index c6737f5..14bb49d 100644 --- a/bench/raw.go +++ b/bench/raw.go @@ -4,7 +4,6 @@ import ( "database/sql" "github.com/efectn/go-orm-benchmarks/helper" "strconv" - "sync" "testing" ) @@ -19,7 +18,6 @@ const ( type Raw struct { helper.ORMInterface - mu sync.Mutex conn *sql.DB } diff --git a/bench/reform.go b/bench/reform.go index 5b638e8..b33fd24 100644 --- a/bench/reform.go +++ b/bench/reform.go @@ -3,7 +3,6 @@ package bench import ( "database/sql" "github.com/efectn/go-orm-benchmarks/helper" - "sync" "testing" r "github.com/efectn/go-orm-benchmarks/bench/reform" @@ -15,7 +14,6 @@ import ( type Reform struct { helper.ORMInterface - mu sync.Mutex conn *reformware.DB db *sql.DB } diff --git a/bench/rel.go b/bench/rel.go index b6b3ece..39418bb 100644 --- a/bench/rel.go +++ b/bench/rel.go @@ -3,7 +3,6 @@ package bench import ( "context" "github.com/efectn/go-orm-benchmarks/helper" - "sync" "testing" "github.com/go-rel/postgres" @@ -13,7 +12,6 @@ import ( type Rel struct { helper.ORMInterface - mu sync.Mutex conn relware.Repository db relware.Adapter } diff --git a/bench/sqlboiler.go b/bench/sqlboiler.go index 7af8241..e9a8ab3 100644 --- a/bench/sqlboiler.go +++ b/bench/sqlboiler.go @@ -3,7 +3,6 @@ package bench import ( "database/sql" "github.com/efectn/go-orm-benchmarks/helper" - "sync" "testing" models "github.com/efectn/go-orm-benchmarks/bench/sqlboiler" @@ -14,7 +13,6 @@ import ( type Sqlboiler struct { helper.ORMInterface - mu sync.Mutex conn *sql.DB } diff --git a/bench/sqlc.go b/bench/sqlc.go index 7d76d81..c3e11c4 100644 --- a/bench/sqlc.go +++ b/bench/sqlc.go @@ -3,7 +3,6 @@ package bench import ( "database/sql" "github.com/efectn/go-orm-benchmarks/helper" - "sync" "testing" "github.com/efectn/go-orm-benchmarks/bench/sqlc/db" @@ -11,7 +10,6 @@ import ( type Sqlc struct { helper.ORMInterface - mu sync.Mutex conn *db.Queries db *sql.DB } diff --git a/bench/sqlx.go b/bench/sqlx.go index 1494865..61ad1b4 100644 --- a/bench/sqlx.go +++ b/bench/sqlx.go @@ -4,7 +4,6 @@ import ( "github.com/efectn/go-orm-benchmarks/helper" sqlxdb "github.com/jmoiron/sqlx" _ "github.com/lib/pq" - "sync" "testing" ) @@ -21,7 +20,6 @@ const ( type Sqlx struct { helper.ORMInterface - mu sync.Mutex conn *sqlxdb.DB } diff --git a/bench/upper.go b/bench/upper.go index 6983e53..c6c01d9 100644 --- a/bench/upper.go +++ b/bench/upper.go @@ -4,13 +4,11 @@ import ( "github.com/efectn/go-orm-benchmarks/helper" db "github.com/upper/db/v4" "github.com/upper/db/v4/adapter/postgresql" - "sync" "testing" ) type Upper struct { helper.ORMInterface - mu sync.Mutex conn db.Session } diff --git a/bench/xorm.go b/bench/xorm.go index c9e592d..d5df093 100644 --- a/bench/xorm.go +++ b/bench/xorm.go @@ -2,14 +2,12 @@ package bench import ( "github.com/efectn/go-orm-benchmarks/helper" - "sync" "testing" xormdb "xorm.io/xorm" ) type Xorm struct { helper.ORMInterface - mu sync.Mutex conn *xormdb.Session } diff --git a/bench/zorm.go b/bench/zorm.go index cf06c14..a9d207f 100644 --- a/bench/zorm.go +++ b/bench/zorm.go @@ -3,7 +3,6 @@ package bench import ( "context" "github.com/efectn/go-orm-benchmarks/helper" - "sync" "testing" zormdb "gitee.com/chunanyong/zorm" @@ -19,7 +18,6 @@ var ( type Zorm struct { helper.ORMInterface - mu sync.Mutex } func CreateZorm() helper.ORMInterface {