Skip to content

Commit 25ac678

Browse files
committed
colblk: fix for BenchmarkUnsafeIntegerSlice
Take the random row index generation out of the measured path. ``` name old time/op new time/op delta UnsafeIntegerSlice/uint64,delta8-10 3.54ns ± 0% 1.25ns ± 1% -64.65% (p=0.029 n=4+4) UnsafeIntegerSlice/uint64,delta4-10 3.44ns ± 0% 0.94ns ± 0% -72.70% (p=0.029 n=4+4) UnsafeIntegerSlice/uint64,delta2-10 3.36ns ± 0% 0.63ns ± 0% -81.36% (p=0.029 n=4+4) UnsafeIntegerSlice/uint64,delta1-10 3.30ns ± 0% 0.63ns ± 1% -80.74% (p=0.029 n=4+4) UnsafeIntegerSlice/uint64,delta0-10 3.30ns ± 1% 0.51ns ± 0% -84.43% (p=0.029 n=4+4) UnsafeIntegerSlice/uint32,delta4-10 3.44ns ± 0% 0.94ns ± 2% -72.55% (p=0.029 n=4+4) UnsafeIntegerSlice/uint32,delta2-10 3.36ns ± 0% 0.63ns ± 1% -81.39% (p=0.029 n=4+4) UnsafeIntegerSlice/uint32,delta1-10 3.34ns ± 3% 0.62ns ± 0% -81.38% (p=0.029 n=4+4) UnsafeIntegerSlice/uint32,delta0-10 3.33ns ± 2% 0.51ns ± 0% -84.80% (p=0.029 n=4+4) UnsafeIntegerSlice/uint16,delta2-10 3.40ns ± 1% 0.64ns ± 5% -81.29% (p=0.029 n=4+4) UnsafeIntegerSlice/uint16,delta1-10 3.30ns ± 0% 0.62ns ± 0% -81.13% (p=0.029 n=4+4) UnsafeIntegerSlice/uint16,delta0-10 3.29ns ± 0% 0.51ns ± 0% -84.63% (p=0.029 n=4+4) UnsafeIntegerSlice/uint8,delta1-10 3.29ns ± 0% 0.62ns ± 0% -81.09% (p=0.029 n=4+4) UnsafeIntegerSlice/uint8,delta0-10 3.30ns ± 0% 0.51ns ± 0% -84.65% (p=0.029 n=4+4) ```
1 parent a6d2952 commit 25ac678

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

sstable/colblk/unsafe_slice_test.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package colblk
66

77
import (
88
"fmt"
9+
"io"
910
"math"
1011
"testing"
1112
"time"
@@ -46,9 +47,16 @@ func benchmarkUnsafeIntegerSlice[U Uint](
4647
buf := aligned.ByteSlice(int(sz) + 1 /* trailing padding byte */)
4748
_ = ub.Finish(0, rows, 0, buf)
4849
s, _ := DecodeUnsafeIntegerSlice[U](buf, 0, rows)
50+
var reads [256]int
51+
for i := range reads {
52+
reads[i] = rng.Intn(rows)
53+
}
4954
b.ResetTimer()
55+
var result uint8
5056
for i := 0; i < b.N; i++ {
51-
_ = s.At(rng.Intn(rows))
57+
result ^= uint8(s.At(reads[i&255]))
5258
}
59+
b.StopTimer()
60+
fmt.Fprint(io.Discard, result)
5361
})
5462
}

0 commit comments

Comments
 (0)