Skip to content

Commit

Permalink
fix actions
Browse files Browse the repository at this point in the history
  • Loading branch information
efectn committed Jun 22, 2023
1 parent f01728a commit 494e4d7
Show file tree
Hide file tree
Showing 23 changed files with 11 additions and 58 deletions.
17 changes: 5 additions & 12 deletions .github/run_benchmarks_actions.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
run: ./main -source="host=localhost user=postgres password=postgres dbname=test sslmode=disable" -orm=all -debug=false
2 changes: 0 additions & 2 deletions bench/beego.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 0 additions & 2 deletions bench/bun.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package bench
import (
"database/sql"
"github.com/efectn/go-orm-benchmarks/helper"
"sync"
"testing"

bundb "github.com/uptrace/bun"
Expand All @@ -13,7 +12,6 @@ import (

type Bun struct {
helper.ORMInterface
mu sync.Mutex
conn *bundb.DB
}

Expand Down
2 changes: 0 additions & 2 deletions bench/dbr.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package bench

import (
"github.com/efectn/go-orm-benchmarks/helper"
"sync"
"testing"

dbrware "github.com/gocraft/dbr/v2"
Expand All @@ -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
}

Expand Down
10 changes: 5 additions & 5 deletions bench/ent.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package bench
import (
"database/sql"
"github.com/efectn/go-orm-benchmarks/helper"
"sync"
"testing"

"entgo.io/ent/dialect"
Expand All @@ -15,7 +14,6 @@ import (

type Ent struct {
helper.ORMInterface
mu sync.Mutex
conn *entdb.Client
dbEnt *sql.DB
}
Expand Down Expand Up @@ -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).
Expand All @@ -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()
Expand All @@ -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).
Expand All @@ -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())
}
Expand Down
2 changes: 0 additions & 2 deletions bench/godb.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 0 additions & 2 deletions bench/gorm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 0 additions & 2 deletions bench/gorm_prep.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 0 additions & 2 deletions bench/gorp.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package bench
import (
"database/sql"
"github.com/efectn/go-orm-benchmarks/helper"
"sync"
"testing"

_ "github.com/jackc/pgx/v4/stdlib"
Expand All @@ -13,7 +12,6 @@ import (

type Gorp struct {
helper.ORMInterface
mu sync.Mutex
conn *gorpware.DbMap
}

Expand Down
2 changes: 0 additions & 2 deletions bench/pg.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 0 additions & 2 deletions bench/pgx.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 0 additions & 2 deletions bench/pgx_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 0 additions & 2 deletions bench/pop.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package bench

import (
"github.com/efectn/go-orm-benchmarks/helper"
"sync"
"testing"

popware "github.com/gobuffalo/pop/v6"
Expand All @@ -11,7 +10,6 @@ import (

type Pop struct {
helper.ORMInterface
mu sync.Mutex
conn *popware.Connection
}

Expand Down
2 changes: 0 additions & 2 deletions bench/raw.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"database/sql"
"github.com/efectn/go-orm-benchmarks/helper"
"strconv"
"sync"
"testing"
)

Expand All @@ -19,7 +18,6 @@ const (

type Raw struct {
helper.ORMInterface
mu sync.Mutex
conn *sql.DB
}

Expand Down
2 changes: 0 additions & 2 deletions bench/reform.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -15,7 +14,6 @@ import (

type Reform struct {
helper.ORMInterface
mu sync.Mutex
conn *reformware.DB
db *sql.DB
}
Expand Down
2 changes: 0 additions & 2 deletions bench/rel.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package bench
import (
"context"
"github.com/efectn/go-orm-benchmarks/helper"
"sync"
"testing"

"github.com/go-rel/postgres"
Expand All @@ -13,7 +12,6 @@ import (

type Rel struct {
helper.ORMInterface
mu sync.Mutex
conn relware.Repository
db relware.Adapter
}
Expand Down
2 changes: 0 additions & 2 deletions bench/sqlboiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -14,7 +13,6 @@ import (

type Sqlboiler struct {
helper.ORMInterface
mu sync.Mutex
conn *sql.DB
}

Expand Down
2 changes: 0 additions & 2 deletions bench/sqlc.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@ package bench
import (
"database/sql"
"github.com/efectn/go-orm-benchmarks/helper"
"sync"
"testing"

"github.com/efectn/go-orm-benchmarks/bench/sqlc/db"
)

type Sqlc struct {
helper.ORMInterface
mu sync.Mutex
conn *db.Queries
db *sql.DB
}
Expand Down
2 changes: 0 additions & 2 deletions bench/sqlx.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"github.com/efectn/go-orm-benchmarks/helper"
sqlxdb "github.com/jmoiron/sqlx"
_ "github.com/lib/pq"
"sync"
"testing"
)

Expand All @@ -21,7 +20,6 @@ const (

type Sqlx struct {
helper.ORMInterface
mu sync.Mutex
conn *sqlxdb.DB
}

Expand Down
2 changes: 0 additions & 2 deletions bench/upper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 0 additions & 2 deletions bench/xorm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 0 additions & 2 deletions bench/zorm.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package bench
import (
"context"
"github.com/efectn/go-orm-benchmarks/helper"
"sync"
"testing"

zormdb "gitee.com/chunanyong/zorm"
Expand All @@ -19,7 +18,6 @@ var (

type Zorm struct {
helper.ORMInterface
mu sync.Mutex
}

func CreateZorm() helper.ORMInterface {
Expand Down

0 comments on commit 494e4d7

Please sign in to comment.