Some extra checks
This commit is contained in:
parent
13e69ab2a1
commit
12db3eac1f
|
@ -18,7 +18,7 @@ func Benchmark_Zombiezen(b *testing.B) {
|
|||
|
||||
// Create and open database
|
||||
|
||||
dbpool, err := sqlitex.Open(filepath.Join(b.TempDir(), "db.db"), sqlite.OpenCreate|sqlite.OpenReadWrite|sqlite.OpenWAL|sqlite.OpenNoMutex, 10)
|
||||
dbpool, err := sqlitex.Open(filepath.Join(b.TempDir(), "db.db"), sqlite.OpenCreate|sqlite.OpenReadWrite|sqlite.OpenWAL|sqlite.OpenNoMutex, 100)
|
||||
require.NoError(b, err)
|
||||
|
||||
// Create table
|
||||
|
@ -42,14 +42,18 @@ func Benchmark_Zombiezen(b *testing.B) {
|
|||
b.Run("Queries", func(b *testing.B) {
|
||||
b.RunParallel(func(p *testing.PB) {
|
||||
for p.Next() {
|
||||
var as, bs, cs string
|
||||
conn := dbpool.Get(context.Background())
|
||||
_ = sqlitex.Exec(conn, "select a, b, c from test where a = ?;", func(stmt *sqlite.Stmt) error {
|
||||
_ = stmt.ColumnText(0)
|
||||
_ = stmt.ColumnText(1)
|
||||
_ = stmt.ColumnText(2)
|
||||
as = stmt.ColumnText(0)
|
||||
bs = stmt.ColumnText(1)
|
||||
cs = stmt.ColumnText(2)
|
||||
return nil
|
||||
}, strconv.Itoa(rand.Intn(1000)))
|
||||
dbpool.Put(conn)
|
||||
if as == "" || bs == "" || cs == "" {
|
||||
b.FailNow()
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
@ -62,7 +66,7 @@ func Benchmark_Mattn(b *testing.B) {
|
|||
|
||||
db, err := sql.Open("sqlite3", filepath.Join(b.TempDir(), "db.db")+"?mode=rwc&_journal_mode=WAL")
|
||||
require.NoError(b, err)
|
||||
db.SetMaxOpenConns(10)
|
||||
db.SetMaxOpenConns(100)
|
||||
|
||||
// Create table
|
||||
|
||||
|
@ -81,10 +85,13 @@ func Benchmark_Mattn(b *testing.B) {
|
|||
b.Run("Queries", func(b *testing.B) {
|
||||
b.RunParallel(func(p *testing.PB) {
|
||||
for p.Next() {
|
||||
var a, b, c string
|
||||
var as, bs, cs string
|
||||
rows, _ := db.Query("select a, b, c from test where a = ?;", strconv.Itoa(rand.Intn(1000)))
|
||||
for rows.Next() {
|
||||
rows.Scan(&a, &b, &c)
|
||||
rows.Scan(&as, &bs, &cs)
|
||||
}
|
||||
if as == "" || bs == "" || cs == "" {
|
||||
b.FailNow()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
Reference in New Issue