Skip to content

Conversation

@bufistov
Copy link

Similar performance. Better memory consumption:

bufistov/bwarr - (main) > make bench
go test -bench=BenchmarkQA -benchtime 1000000x ./... | tee qa/bench.tmp
goos: darwin
goarch: arm64
pkg: github.com/dronnix/bwarr
cpu: Apple M3 Pro
BenchmarkQA_Insert-12                            1000000               170.2 ns/op            37 B/op          0 allocs/op
BenchmarkQA_ReplaceOrInsertNotFound-12           1000000              1420 ns/op              37 B/op          0 allocs/op
BenchmarkQA_ReplaceOrInsertFound-12              1000000               238.4 ns/op        33.56 MB/s           0 B/op          0 allocs/op
BenchmarkQA_HasFound-12                          1000000               222.3 ns/op        35.98 MB/s           0 B/op          0 allocs/op
BenchmarkQA_HasNotFoundWorst-12                  1000000              2302 ns/op           3.48 MB/s           0 B/op          0 allocs/op
BenchmarkQA_Min-12                               1000000                79.11 ns/op            0 B/op          0 allocs/op
BenchmarkQA_Max-12                               1000000                80.65 ns/op            0 B/op          0 allocs/op
BenchmarkQA_Delete-12                            1000000               698.0 ns/op             0 B/op          0 allocs/op
BenchmarkQA_DeleteMin-12                         1000000                43.05 ns/op            0 B/op          0 allocs/op
BenchmarkQA_DeleteMax-12                         1000000                38.97 ns/op            0 B/op          0 allocs/op
PASS
ok      github.com/dronnix/bwarr        17.607s
go test -bench=BenchmarkLongQA -benchtime 2s ./... | tee -a qa/bench.tmp
goos: darwin
goarch: arm64
pkg: github.com/dronnix/bwarr
cpu: Apple M3 Pro
BenchmarkLongQA_NewFromSlice-12                              295           8076932 ns/op         1180973 B/op         36 allocs/op
BenchmarkLongQA_InsertRandom-12                              189          12711830 ns/op         1181006 B/op         51 allocs/op
BenchmarkLongQA_AscendRandom-12                             1012           2396383 ns/op            1680 B/op          2 allocs/op
BenchmarkLongQA_AscendInc-12                                3976            597361 ns/op            1680 B/op          2 allocs/op
BenchmarkLongQA_AscendDec-12                                4969            478657 ns/op            1680 B/op          2 allocs/op
BenchmarkLongQA_AscendRange-12                              4171            581655 ns/op            1680 B/op          2 allocs/op
BenchmarkLongQA_AscendWithDelSeries-12                      4129            588143 ns/op            1680 B/op          2 allocs/op
BenchmarkLongQA_DescendRandom-12                            1011           2409262 ns/op            1680 B/op          2 allocs/op
BenchmarkLongQA_DescendRangeWithDelSeries-12                5113            473545 ns/op            1680 B/op          2 allocs/op
BenchmarkLongQA_UnorderedWalkRandom-12                     29972             91186 ns/op               0 B/op          0 allocs/op
BenchmarkLongQA_UnorderedWalkWithDelSeries-12              29854             82871 ns/op               0 B/op          0 allocs/op
PASS
ok      github.com/dronnix/bwarr        31.798s
cat qa/bench.tmp | gobenchdata --json qa/cur_bench.json
detected 2 benchmark suites
successfully output results as json to 'qa/cur_bench.json'
gobenchdata checks eval --checks.config qa/gobenchdata-checks.yml qa/dmitry_last_bench.json qa/cur_bench.json --json qa/rep.json
report output written to qa/rep.json
gobenchdata checks --checks.config qa/gobenchdata-checks.yml report qa/rep.json
|    | BASE | CURRENT | PASSED CHECKS | FAILED CHECKS | TOTAL |
|----|------|---------|---------------|---------------|-------|
| ❌ |      |         |             0 |             1 |     1 |

|    | CHECK |         PACKAGE          |                   BENCHMARK                   |  DIFF  |            COMMENT             |
|----|-------|--------------------------|-----------------------------------------------|--------|--------------------------------|
| ✅ |       | github.com/dronnix/bwarr | BenchmarkQA_Insert-12                         |   3.91 |                                |
| ✅ |       | github.com/dronnix/bwarr | BenchmarkQA_ReplaceOrInsertNotFound-12        |   5.03 |                                |
| ✅ |       | github.com/dronnix/bwarr | BenchmarkQA_ReplaceOrInsertFound-12           |   3.79 |                                |
| ✅ |       | github.com/dronnix/bwarr | BenchmarkQA_HasFound-12                       | -20.61 |                                |
| ✅ |       | github.com/dronnix/bwarr | BenchmarkQA_HasNotFoundWorst-12               |  -3.20 |                                |
| ✅ |       | github.com/dronnix/bwarr | BenchmarkQA_Min-12                            | -26.48 |                                |
| ❌ |       | github.com/dronnix/bwarr | BenchmarkQA_Max-12                            |  10.21 | exceeded maximum 10.000000     |
|    |       |                          |                                               |        | (+0.21)                        |
| ✅ |       | github.com/dronnix/bwarr | BenchmarkQA_Delete-12                         |  -1.11 |                                |
| ✅ |       | github.com/dronnix/bwarr | BenchmarkQA_DeleteMin-12                      |   3.41 |                                |
| ✅ |       | github.com/dronnix/bwarr | BenchmarkQA_DeleteMax-12                      |   3.48 |                                |
| ✅ |       | github.com/dronnix/bwarr | BenchmarkLongQA_NewFromSlice-12               |  -2.47 |                                |
| ✅ |       | github.com/dronnix/bwarr | BenchmarkLongQA_InsertRandom-12               |   0.94 |                                |
| ✅ |       | github.com/dronnix/bwarr | BenchmarkLongQA_AscendRandom-12               |   0.30 |                                |
| ✅ |       | github.com/dronnix/bwarr | BenchmarkLongQA_AscendInc-12                  |   1.87 |                                |
| ✅ |       | github.com/dronnix/bwarr | BenchmarkLongQA_AscendDec-12                  |   0.38 |                                |
| ✅ |       | github.com/dronnix/bwarr | BenchmarkLongQA_AscendRange-12                |  -2.02 |                                |
| ✅ |       | github.com/dronnix/bwarr | BenchmarkLongQA_AscendWithDelSeries-12        |  -0.41 |                                |
| ✅ |       | github.com/dronnix/bwarr | BenchmarkLongQA_DescendRandom-12              |   0.26 |                                |
| ✅ |       | github.com/dronnix/bwarr | BenchmarkLongQA_DescendRangeWithDelSeries-12  |  -1.32 |                                |
| ❌ |       | github.com/dronnix/bwarr | BenchmarkLongQA_UnorderedWalkRandom-12        |  12.03 | exceeded maximum 10.000000     |
|    |       |                          |                                               |        | (+2.03)                        |
| ✅ |       | github.com/dronnix/bwarr | BenchmarkLongQA_UnorderedWalkWithDelSeries-12 |   4.19 |                                |

make: *** [bench] Error 1

dmitry-workato and others added 3 commits January 17, 2026 11:56
I got some linter failure about non-modern
slice.sort() call and the benchmark check is using suffix '12'
for the comparison.
Make build work on my laptop.
Normal arrays are enough to implement all the operations.
@bufistov bufistov marked this pull request as draft January 17, 2026 14:23
@bufistov
Copy link
Author

bwarr_alloc_test.go should be fixed. The number of allocations reduced everywhere.

I undo the 'copy' function usage at the tail of the merge
function as it steadily downgrades result of both Insert benchmarks
by 5%.
@bufistov
Copy link
Author

Results with the latests commit:

bufistov/bwarr - (main) > make
go test -count 1 ./...
ok      github.com/dronnix/bwarr        0.272s
golangci-lint run -c qa/.golangci.yml
0 issues.
go test -bench=BenchmarkQA -benchtime 1000000x ./... | tee qa/bench.tmp
goos: darwin
goarch: arm64
pkg: github.com/dronnix/bwarr
cpu: Apple M3 Pro
BenchmarkQA_Insert-12                            1000000               161.3 ns/op            37 B/op          0 allocs/op
BenchmarkQA_ReplaceOrInsertNotFound-12           1000000              1443 ns/op              37 B/op          0 allocs/op
BenchmarkQA_ReplaceOrInsertFound-12              1000000               245.7 ns/op        32.57 MB/s           0 B/op          0 allocs/op
BenchmarkQA_HasFound-12                          1000000               221.3 ns/op        36.15 MB/s           0 B/op          0 allocs/op
BenchmarkQA_HasNotFoundWorst-12                  1000000              2227 ns/op           3.59 MB/s           0 B/op          0 allocs/op
BenchmarkQA_Min-12                               1000000                66.73 ns/op            0 B/op          0 allocs/op
BenchmarkQA_Max-12                               1000000                76.65 ns/op            0 B/op          0 allocs/op
BenchmarkQA_Delete-12                            1000000               677.4 ns/op             0 B/op          0 allocs/op
BenchmarkQA_DeleteMin-12                         1000000                38.22 ns/op            0 B/op          0 allocs/op
BenchmarkQA_DeleteMax-12                         1000000                38.38 ns/op            0 B/op          0 allocs/op
PASS
ok      github.com/dronnix/bwarr        16.818s
go test -bench=BenchmarkLongQA -benchtime 2s ./... | tee -a qa/bench.tmp
goos: darwin
goarch: arm64
pkg: github.com/dronnix/bwarr
cpu: Apple M3 Pro
BenchmarkLongQA_NewFromSlice-12                              296           8068297 ns/op         1180974 B/op         36 allocs/op
BenchmarkLongQA_InsertRandom-12                              196          12084050 ns/op         1181005 B/op         51 allocs/op
BenchmarkLongQA_AscendRandom-12                             1018           2376341 ns/op            1680 B/op          2 allocs/op
BenchmarkLongQA_AscendInc-12                                3350            609055 ns/op            1680 B/op          2 allocs/op
BenchmarkLongQA_AscendDec-12                                5026            477476 ns/op            1680 B/op          2 allocs/op
BenchmarkLongQA_AscendRange-12                              4173            599068 ns/op            1680 B/op          2 allocs/op
BenchmarkLongQA_AscendWithDelSeries-12                      4035            582833 ns/op            1680 B/op          2 allocs/op
BenchmarkLongQA_DescendRandom-12                            1008           2378342 ns/op            1680 B/op          2 allocs/op
BenchmarkLongQA_DescendRangeWithDelSeries-12                5046            477404 ns/op            1680 B/op          2 allocs/op
BenchmarkLongQA_UnorderedWalkRandom-12                     23499             93347 ns/op               0 B/op          0 allocs/op
BenchmarkLongQA_UnorderedWalkWithDelSeries-12              30384             79144 ns/op               0 B/op          0 allocs/op
PASS
ok      github.com/dronnix/bwarr        30.973s
cat qa/bench.tmp | gobenchdata --json qa/cur_bench.json
detected 2 benchmark suites
successfully output results as json to 'qa/cur_bench.json'
gobenchdata checks eval --checks.config qa/gobenchdata-checks.yml qa/dmitry_last_bench.json qa/cur_bench.json --json qa/rep.json
report output written to qa/rep.json
gobenchdata checks --checks.config qa/gobenchdata-checks.yml report qa/rep.json
|    | BASE | CURRENT | PASSED CHECKS | FAILED CHECKS | TOTAL |
|----|------|---------|---------------|---------------|-------|
| ❌ |      |         |             0 |             1 |     1 |

|    | CHECK |         PACKAGE          |                   BENCHMARK                   |  DIFF  |            COMMENT             |
|----|-------|--------------------------|-----------------------------------------------|--------|--------------------------------|
| ✅ |       | github.com/dronnix/bwarr | BenchmarkQA_Insert-12                         |  -1.53 |                                |
| ✅ |       | github.com/dronnix/bwarr | BenchmarkQA_ReplaceOrInsertNotFound-12        |   6.73 |                                |
| ✅ |       | github.com/dronnix/bwarr | BenchmarkQA_ReplaceOrInsertFound-12           |   6.97 |                                |
| ✅ |       | github.com/dronnix/bwarr | BenchmarkQA_HasFound-12                       | -20.96 |                                |
| ✅ |       | github.com/dronnix/bwarr | BenchmarkQA_HasNotFoundWorst-12               |  -6.35 |                                |
| ✅ |       | github.com/dronnix/bwarr | BenchmarkQA_Min-12                            | -37.98 |                                |
| ✅ |       | github.com/dronnix/bwarr | BenchmarkQA_Max-12                            |   4.74 |                                |
| ✅ |       | github.com/dronnix/bwarr | BenchmarkQA_Delete-12                         |  -4.02 |                                |
| ✅ |       | github.com/dronnix/bwarr | BenchmarkQA_DeleteMin-12                      |  -8.19 |                                |
| ✅ |       | github.com/dronnix/bwarr | BenchmarkQA_DeleteMax-12                      |   1.91 |                                |
| ✅ |       | github.com/dronnix/bwarr | BenchmarkLongQA_NewFromSlice-12               |  -2.57 |                                |
| ✅ |       | github.com/dronnix/bwarr | BenchmarkLongQA_InsertRandom-12               |  -4.05 |                                |
| ✅ |       | github.com/dronnix/bwarr | BenchmarkLongQA_AscendRandom-12               |  -0.54 |                                |
| ✅ |       | github.com/dronnix/bwarr | BenchmarkLongQA_AscendInc-12                  |   3.87 |                                |
| ✅ |       | github.com/dronnix/bwarr | BenchmarkLongQA_AscendDec-12                  |   0.13 |                                |
| ✅ |       | github.com/dronnix/bwarr | BenchmarkLongQA_AscendRange-12                |   0.92 |                                |
| ✅ |       | github.com/dronnix/bwarr | BenchmarkLongQA_AscendWithDelSeries-12        |  -1.31 |                                |
| ✅ |       | github.com/dronnix/bwarr | BenchmarkLongQA_DescendRandom-12              |  -1.02 |                                |
| ✅ |       | github.com/dronnix/bwarr | BenchmarkLongQA_DescendRangeWithDelSeries-12  |  -0.52 |                                |
| ❌ |       | github.com/dronnix/bwarr | BenchmarkLongQA_UnorderedWalkRandom-12        |  14.69 | exceeded maximum 10.000000     |
|    |       |                          |                                               |        | (+4.69)                        |
| ✅ |       | github.com/dronnix/bwarr | BenchmarkLongQA_UnorderedWalkWithDelSeries-12 |  -0.50 |                                |

make: *** [bench] Error 1

@bufistov bufistov marked this pull request as ready for review January 18, 2026 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants