good morning!!!!

Skip to content
Snippets Groups Projects
Commit d738e77d authored by Carlos Reventlov's avatar Carlos Reventlov
Browse files

Merge pull request #22 from wei2912/master

sqlite: Benchmark applying BEGIN and END transaction optimizations
parents 100dea4f c1918243
Branches
Tags
No related merge requests found
......@@ -103,7 +103,6 @@ func TestTruncate(t *testing.T) {
// Appends maps and structs.
func TestAppend(t *testing.T) {
sess, err := db.Open(wrapperName, settings)
if err != nil {
......@@ -189,7 +188,6 @@ func TestAppend(t *testing.T) {
// Tries to find and fetch rows.
func TestFind(t *testing.T) {
var err error
var res db.Result
......@@ -320,7 +318,6 @@ func TestFind(t *testing.T) {
// Tests limit and offset.
func TestLimitOffset(t *testing.T) {
var err error
sess, err := db.Open(wrapperName, settings)
......@@ -398,7 +395,6 @@ func TestUpdate(t *testing.T) {
// Tries to add test data and relations.
func TestPopulate(t *testing.T) {
sess, err := db.Open(wrapperName, settings)
if err != nil {
......@@ -786,6 +782,42 @@ func BenchmarkAppendDbItem(b *testing.B) {
}
}
// Contributed by wei2912
// See: https://github.com/gosexy/db/issues/20#issuecomment-20167939
// Applying the BEGIN and END transaction optimizations.
func BenchmarkAppendDbItem_Transaction(b *testing.B) {
sess, err := db.Open(wrapperName, settings)
if err != nil {
b.Fatalf(err.Error())
}
defer sess.Close()
people := sess.ExistentCollection("people")
people.Truncate()
driver := sess.Driver().(*sql.DB)
b.ResetTimer()
_, err = driver.Exec(`BEGIN`)
if err != nil {
b.Fatalf(err.Error())
}
for i := 0; i < b.N; i++ {
_, err = people.Append(db.Item{"name": "john"})
if err != nil {
b.Fatalf(err.Error())
}
}
_, err = driver.Exec(`END`)
if err != nil {
b.Fatalf(err.Error())
}
}
func BenchmarkAppendStruct(b *testing.B) {
sess, err := db.Open(wrapperName, settings)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment