Skip to content

Commit

Permalink
Merge branch 'refs/heads/master' into more-benchmarks
Browse files Browse the repository at this point in the history
# Conflicts:
#	mdbx/cursor_test.go
  • Loading branch information
JkLondon committed Jul 15, 2024
2 parents f920218 + c531783 commit 721c73e
Showing 1 changed file with 47 additions and 2 deletions.
49 changes: 47 additions & 2 deletions mdbx/cursor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1567,7 +1567,7 @@ func BenchmarkCursor_Renew(b *testing.B) {
})
}

func BenchmarkCursor_SetRange_OneKey(b *testing.B) {
func BenchmarkCursor_Set_OneKey(b *testing.B) {
env, _ := setup(b)

var db DBI
Expand Down Expand Up @@ -1635,6 +1635,51 @@ func BenchmarkCursor_SetRange_Sequence(b *testing.B) {
return
}

if err := env.View(func(txn *Txn) (err error) {
c, err := txn.OpenCursor(db)
if err != nil {
return err
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
_, _, err := c.Get(k, nil, Set)
if err != nil {
return err
}
}
return nil
}); err != nil {
b.Errorf("put: %v", err)
}
}

func BenchmarkCursor_Set_Sequence(b *testing.B) {
env, _ := setup(b)

var db DBI
keys := make([][]byte, b.N, b.N)
for i := range keys {
keys[i] = make([]byte, 8)
binary.BigEndian.PutUint64(keys[i], uint64(i))
}

if err := env.Update(func(txn *Txn) (err error) {
db, err = txn.OpenRoot(0)
if err != nil {
return err
}
for _, k := range keys {
err = txn.Put(db, k, k, 0)
if err != nil {
return err
}
}
return nil
}); err != nil {
b.Errorf("dbi: %v", err)
return
}

if err := env.View(func(txn *Txn) (err error) {
c, err := txn.OpenCursor(db)
if err != nil {
Expand All @@ -1653,7 +1698,7 @@ func BenchmarkCursor_SetRange_Sequence(b *testing.B) {
}
}

func BenchmarkCursor_SetRange_Random(b *testing.B) {
func BenchmarkCursor_Set_Random(b *testing.B) {
env, _ := setup(b)

var db DBI
Expand Down

0 comments on commit 721c73e

Please sign in to comment.