Skip to content

Commit

Permalink
update benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
kelindar committed Dec 15, 2021
1 parent 56a41dc commit 475f0ab
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 16 deletions.
13 changes: 11 additions & 2 deletions collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,17 @@ func (c *columns) Count() int {
return len(cols)
}

// Range iterates over columns in the registry.
func (c *columns) Range(fn func(column *column) error) error {
// Range iterates over columns in the registry. This is faster than RangeUntil
// method.
func (c *columns) Range(fn func(column *column)) {
cols := c.cols.Load().([]columnEntry)
for _, v := range cols {
fn(v.cols[0])
}
}

// RangeUntil iterates over columns in the registry until an error occurs.
func (c *columns) RangeUntil(fn func(column *column) error) error {
cols := c.cols.Load().([]columnEntry)
for _, v := range cols {
if err := fn(v.cols[0]); err != nil {
Expand Down
18 changes: 9 additions & 9 deletions collection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ import (

/*
cpu: Intel(R) Core(TM) i7-9700K CPU @ 3.60GHz
BenchmarkCollection/insert-8 2608 519498 ns/op 24298 B/op 500 allocs/op
BenchmarkCollection/select-at-8 42467803 27.63 ns/op 0 B/op 0 allocs/op
BenchmarkCollection/scan-8 1976 574104 ns/op 88 B/op 0 allocs/op
BenchmarkCollection/count-8 783828 1516 ns/op 0 B/op 0 allocs/op
BenchmarkCollection/range-8 17836 67879 ns/op 6 B/op 0 allocs/op
BenchmarkCollection/update-at-8 3707148 322.9 ns/op 0 B/op 0 allocs/op
BenchmarkCollection/update-all-8 1183 976786 ns/op 4025 B/op 0 allocs/op
BenchmarkCollection/delete-at-8 9005782 130.1 ns/op 0 B/op 0 allocs/op
BenchmarkCollection/delete-all-8 2359329 493.3 ns/op 0 B/op 0 allocs/op
BenchmarkCollection/insert-8 2174 534746 ns/op 25090 B/op 500 allocs/op
BenchmarkCollection/select-at-8 42206409 28.19 ns/op 0 B/op 0 allocs/op
BenchmarkCollection/scan-8 2116 581193 ns/op 1872 B/op 0 allocs/op
BenchmarkCollection/count-8 748689 1565 ns/op 5 B/op 0 allocs/op
BenchmarkCollection/range-8 16476 73244 ns/op 216 B/op 0 allocs/op
BenchmarkCollection/update-at-8 3717255 316.6 ns/op 1 B/op 0 allocs/op
BenchmarkCollection/update-all-8 1176 1005992 ns/op 7134 B/op 1 allocs/op
BenchmarkCollection/delete-at-8 8403426 145.0 ns/op 0 B/op 0 allocs/op
BenchmarkCollection/delete-all-8 2338410 500.0 ns/op 1 B/op 0 allocs/op
*/
func BenchmarkCollection(b *testing.B) {
b.Run("insert", func(b *testing.B) {
Expand Down
2 changes: 1 addition & 1 deletion snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (c *Collection) WriteTo(dst io.Writer) (int64, error) {
}

// Snapshot each column and write the buffer
return c.cols.Range(func(column *column) error {
return c.cols.RangeUntil(func(column *column) error {
buffer.Reset(column.name)
column.Snapshot(chunk, buffer)
return writer.WriteSelf(buffer)
Expand Down
6 changes: 2 additions & 4 deletions txn.go
Original file line number Diff line number Diff line change
Expand Up @@ -501,9 +501,8 @@ func (txn *Txn) commitMarkers(chunk commit.Chunk, fill bitmap.Bitmap, buffer *co
// We also need to apply the delete operations on the column so it
// can remove unnecessary data.
txn.reader.Range(buffer, chunk, func(r *commit.Reader) {
txn.owner.cols.Range(func(column *column) error {
txn.owner.cols.Range(func(column *column) {
column.Apply(r)
return nil
})
})

Expand All @@ -529,8 +528,7 @@ func (txn *Txn) commitCapacity(max uint32) {

// Grow the fill list and all of the owner's columns
txn.owner.fill.Grow(max)
txn.owner.cols.Range(func(column *column) error {
txn.owner.cols.Range(func(column *column) {
column.Grow(max)
return nil
})
}

0 comments on commit 475f0ab

Please sign in to comment.