Skip to content

Commit

Permalink
fix benchmarks, modify test-all so it will append arguments to go tes…
Browse files Browse the repository at this point in the history
…t meaning that bench_all is no longer necessary, add benchmark results on my machine to benchmarks.md
  • Loading branch information
jmoiron committed Jun 6, 2013
1 parent 6968ba4 commit 794a78b
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 42 deletions.
30 changes: 0 additions & 30 deletions bench_all.sh

This file was deleted.

17 changes: 17 additions & 0 deletions benchmarks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Current benchmarks:

PASS
BenchmarkNativeCrud 100 22605756 ns/op 5402 B/op 107 allocs/op
BenchmarkModlCrud 100 21107020 ns/op 7329 B/op 153 allocs/op
ok _/mnt/omocha/jmoiron/dev/go/modl 5.975s
PASS
BenchmarkNativeCrud 100 13153419 ns/op 8822 B/op 334 allocs/op
BenchmarkModlCrud 100 11676837 ns/op 10577 B/op 381 allocs/op
ok _/mnt/omocha/jmoiron/dev/go/modl 3.813s
PASS
BenchmarkNativeCrud 5000 281356 ns/op 1455 B/op 51 allocs/op
BenchmarkModlCrud 5000 313549 ns/op 2713 B/op 90 allocs/op
ok _/mnt/omocha/jmoiron/dev/go/modl 3.136s

(In order: MySQL, PostgreSQL, SQLite)

17 changes: 9 additions & 8 deletions modl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -581,12 +581,13 @@ func BenchmarkNativeCrud(b *testing.B) {
defer dbmap.DropTables()
b.StartTimer()

insert := "insert into invoice_test (Created, Updated, Memo, PersonId) values (?, ?, ?, ?)"
sel := "select Id, Created, Updated, Memo, PersonId from invoice_test where Id=?"
update := "update invoice_test set Created=?, Updated=?, Memo=?, PersonId=? where Id=?"
delete := "delete from invoice_test where Id=?"
insert := "insert into invoice_test (date_created, updated, memo, personid) values (?, ?, ?, ?)"
sel := "select id, date_created, updated, memo, personid from invoice_test where id=?"
update := "update invoice_test set date_created=?, updated=?, memo=?, personid=? where id=?"
delete := "delete from invoice_test where id=?"

suffix := dbmap.Dialect.AutoIncrInsertSuffix(&ColumnMap{ColumnName: "id"})

suffix := dbmap.Dialect.AutoIncrInsertSuffix(&ColumnMap{ColumnName: "Id"})
insert = ReBind(insert, dbmap.Dialect) + suffix
sel = ReBind(sel, dbmap.Dialect)
update = ReBind(update, dbmap.Dialect)
Expand Down Expand Up @@ -647,7 +648,7 @@ func BenchmarkNativeCrud(b *testing.B) {

}

func BenchmarkGorpCrud(b *testing.B) {
func BenchmarkModlCrud(b *testing.B) {
b.StopTimer()
dbmap := initDbMapBench()
defer dbmap.DropTables()
Expand All @@ -671,12 +672,12 @@ func BenchmarkGorpCrud(b *testing.B) {
inv2.Updated = 2000
inv2.Memo = "my memo 2"
inv2.PersonId = 3000
_, err = dbmap.Update(inv2)
_, err = dbmap.Update(&inv2)
if err != nil {
panic(err)
}

_, err = dbmap.Delete(inv2)
_, err = dbmap.Delete(&inv2)
if err != nil {
panic(err)
}
Expand Down
11 changes: 7 additions & 4 deletions test-all
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
# In addition to this, you can create an `environ` file in this directory which
# will be sourced and ignored by git.
#

# Additional arguments to test-all will be used after go-test, so to run
# the benchmark suite on all dbs you can do:
# ./test-all -bench=. -benchmem
#

if [ -f "./environ" ]; then
. ./environ
Expand All @@ -22,7 +25,7 @@ set -e
if [ -n "$MODL_MYSQL_DSN" ]; then
export MODL_TEST_DSN="$MODL_MYSQL_DSN"
export MODL_TEST_DIALECT="mysql"
go test
go test $@
else
echo "Skipping MySQL, \$MODL_MYSQL_DSN=$MODL_MYSQL_DSN"
if [ -n "$MODL_FAIL_ON_SKIP" ]; then
Expand All @@ -33,7 +36,7 @@ fi
if [ -n "$MODL_POSTGRES_DSN" ]; then
export MODL_TEST_DSN="$MODL_POSTGRES_DSN"
export MODL_TEST_DIALECT="postgres"
go test
go test $@
else
echo "Skipping PostgreSQL, \$MODL_POSTGRES_DSN=$MODL_POSTGRES_DSN"
if [ -n "$MODL_FAIL_ON_SKIP" ]; then
Expand All @@ -44,7 +47,7 @@ fi
if [ -n "$MODL_SQLITE_DSN" ]; then
export MODL_TEST_DSN="$MODL_SQLITE_DSN"
export MODL_TEST_DIALECT="sqlite"
go test
go test $@
else
echo "Skipping SQLite, \$MODL_SQLITE_DSN=$MODL_SQLITE_DSN"
if [ -n "$MODL_FAIL_ON_SKIP" ]; then
Expand Down

0 comments on commit 794a78b

Please sign in to comment.