Commit 794a78b4 authored by Jason Moiron's avatar Jason Moiron

fix benchmarks, modify test-all so it will append arguments to go test meaning...

fix benchmarks, modify test-all so it will append arguments to go test meaning that bench_all is no longer necessary, add benchmark results on my machine to benchmarks.md
parent 6968ba41
#!/bin/sh
#set -e
export GORP_TEST_DSN="gorptest/gorptest/"
export GORP_TEST_DIALECT="mysql"
go test -bench . -benchmem
export GORP_TEST_DSN="user=$USER dbname=gorptest sslmode=disable"
export GORP_TEST_DIALECT="postgres"
go test -bench . -benchmem
export GORP_TEST_DSN="/tmp/gorptest.bin"
export GORP_TEST_DIALECT="sqlite"
go test -bench . -benchmem
# PASS
# BenchmarkNativeCrud 2000 872061 ns/op 5364 B/op 106 allocs/op
# BenchmarkGorpCrud 2000 918331 ns/op 7257 B/op 159 allocs/op
# ok _/Users/jmoiron/dev/go/gorp 4.413s
# PASS
# BenchmarkNativeCrud 1000 1468223 ns/op 8833 B/op 335 allocs/op
# BenchmarkGorpCrud 1000 1485000 ns/op 11585 B/op 390 allocs/op
# ok _/Users/jmoiron/dev/go/gorp 3.664s
# PASS
# BenchmarkNativeCrud 1000 1761324 ns/op 1446 B/op 51 allocs/op
# BenchmarkGorpCrud 1000 1733306 ns/op 2942 B/op 99 allocs/op
# ok _/Users/jmoiron/dev/go/gorp 3.977s
#
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)
......@@ -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)
......@@ -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()
......@@ -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)
}
......
......@@ -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
......@@ -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
......@@ -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
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment