Skip to content

Commit d405277

Browse files
committed
better benchmarks
1 parent 68225e2 commit d405277

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

fulltable_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ func init() {
5555
var (
5656
intSink int
5757
boolSink bool
58-
anySink any
5958
)
6059

6160
func init() {

node_test.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import (
1717
"github.com/gaissmai/bart/internal/art"
1818
)
1919

20+
var uintSliceSink []uint
21+
2022
func TestInverseIndex(t *testing.T) {
2123
t.Parallel()
2224
for i := range maxItems {
@@ -279,9 +281,10 @@ func BenchmarkNodePrefixesAsSlice(b *testing.B) {
279281
}
280282

281283
b.Run(fmt.Sprintf("Set %d", nPrefixes), func(b *testing.B) {
284+
buf := make([]uint, maxItems)
282285
b.ResetTimer()
283286
for range b.N {
284-
anySink = this.prefixes.AsSlice(make([]uint, 0, maxItems))
287+
uintSliceSink = this.prefixes.AsSlice(buf)
285288
}
286289
})
287290
}
@@ -299,7 +302,7 @@ func BenchmarkNodePrefixesAll(b *testing.B) {
299302
b.Run(fmt.Sprintf("Set %d", nPrefixes), func(b *testing.B) {
300303
b.ResetTimer()
301304
for range b.N {
302-
anySink = this.prefixes.All()
305+
uintSliceSink = this.prefixes.All()
303306
}
304307
})
305308

@@ -387,9 +390,10 @@ func BenchmarkNodeChildrenAsSlice(b *testing.B) {
387390
}
388391

389392
b.Run(fmt.Sprintf("Set %d", nchilds), func(b *testing.B) {
393+
buf := make([]uint, maxItems)
390394
b.ResetTimer()
391395
for range b.N {
392-
anySink = this.children.AsSlice(make([]uint, 0, maxItems))
396+
uintSliceSink = this.children.AsSlice(buf)
393397
}
394398
})
395399
}
@@ -407,7 +411,7 @@ func BenchmarkNodeChildrenAll(b *testing.B) {
407411
b.Run(fmt.Sprintf("Set %d", nchilds), func(b *testing.B) {
408412
b.ResetTimer()
409413
for range b.N {
410-
anySink = this.children.All()
414+
uintSliceSink = this.children.All()
411415
}
412416
})
413417
}

0 commit comments

Comments
 (0)