Skip to content

Commit

Permalink
kv/tscache: create new IntervalSkl encode/decode benchmarks
Browse files Browse the repository at this point in the history
```
name                                                             time/op
IntervalSklDecodeValue/logical=false,synthetic=false,txnID=false-16  11.7ns ± 2%
IntervalSklDecodeValue/logical=false,synthetic=false,txnID=true-16   11.7ns ± 1%
IntervalSklDecodeValue/logical=false,synthetic=true,txnID=false-16   11.8ns ± 1%
IntervalSklDecodeValue/logical=false,synthetic=true,txnID=true-16    11.7ns ± 0%
IntervalSklDecodeValue/logical=true,synthetic=false,txnID=false-16   11.7ns ± 2%
IntervalSklDecodeValue/logical=true,synthetic=false,txnID=true-16    11.7ns ± 1%
IntervalSklDecodeValue/logical=true,synthetic=true,txnID=false-16    11.7ns ± 1%
IntervalSklDecodeValue/logical=true,synthetic=true,txnID=true-16     11.7ns ± 2%
IntervalSklEncodeValue/logical=false,synthetic=false,txnID=false-16  6.25ns ± 1%
IntervalSklEncodeValue/logical=false,synthetic=false,txnID=true-16   6.25ns ± 1%
IntervalSklEncodeValue/logical=false,synthetic=true,txnID=false-16   6.23ns ± 2%
IntervalSklEncodeValue/logical=false,synthetic=true,txnID=true-16    6.23ns ± 2%
IntervalSklEncodeValue/logical=true,synthetic=false,txnID=false-16   6.26ns ± 3%
IntervalSklEncodeValue/logical=true,synthetic=false,txnID=true-16    6.24ns ± 1%
IntervalSklEncodeValue/logical=true,synthetic=true,txnID=false-16    6.29ns ± 3%
IntervalSklEncodeValue/logical=true,synthetic=true,txnID=true-16     6.23ns ± 2%

name                                                             alloc/op
IntervalSklDecodeValue/logical=false,synthetic=false,txnID=false-16   0.00B
IntervalSklDecodeValue/logical=false,synthetic=false,txnID=true-16    0.00B
IntervalSklDecodeValue/logical=false,synthetic=true,txnID=false-16    0.00B
IntervalSklDecodeValue/logical=false,synthetic=true,txnID=true-16     0.00B
IntervalSklDecodeValue/logical=true,synthetic=false,txnID=false-16    0.00B
IntervalSklDecodeValue/logical=true,synthetic=false,txnID=true-16     0.00B
IntervalSklDecodeValue/logical=true,synthetic=true,txnID=false-16     0.00B
IntervalSklDecodeValue/logical=true,synthetic=true,txnID=true-16      0.00B
IntervalSklEncodeValue/logical=false,synthetic=false,txnID=false-16   0.00B
IntervalSklEncodeValue/logical=false,synthetic=false,txnID=true-16    0.00B
IntervalSklEncodeValue/logical=false,synthetic=true,txnID=false-16    0.00B
IntervalSklEncodeValue/logical=false,synthetic=true,txnID=true-16     0.00B
IntervalSklEncodeValue/logical=true,synthetic=false,txnID=false-16    0.00B
IntervalSklEncodeValue/logical=true,synthetic=false,txnID=true-16     0.00B
IntervalSklEncodeValue/logical=true,synthetic=true,txnID=false-16     0.00B
IntervalSklEncodeValue/logical=true,synthetic=true,txnID=true-16      0.00B

name                                                             allocs/op
IntervalSklDecodeValue/logical=false,synthetic=false,txnID=false-16    0.00
IntervalSklDecodeValue/logical=false,synthetic=false,txnID=true-16     0.00
IntervalSklDecodeValue/logical=false,synthetic=true,txnID=false-16     0.00
IntervalSklDecodeValue/logical=false,synthetic=true,txnID=true-16      0.00
IntervalSklDecodeValue/logical=true,synthetic=false,txnID=false-16     0.00
IntervalSklDecodeValue/logical=true,synthetic=false,txnID=true-16      0.00
IntervalSklDecodeValue/logical=true,synthetic=true,txnID=false-16      0.00
IntervalSklDecodeValue/logical=true,synthetic=true,txnID=true-16       0.00
IntervalSklEncodeValue/logical=false,synthetic=false,txnID=false-16    0.00
IntervalSklEncodeValue/logical=false,synthetic=false,txnID=true-16     0.00
IntervalSklEncodeValue/logical=false,synthetic=true,txnID=false-16     0.00
IntervalSklEncodeValue/logical=false,synthetic=true,txnID=true-16      0.00
IntervalSklEncodeValue/logical=true,synthetic=false,txnID=false-16     0.00
IntervalSklEncodeValue/logical=true,synthetic=false,txnID=true-16      0.00
IntervalSklEncodeValue/logical=true,synthetic=true,txnID=false-16      0.00
IntervalSklEncodeValue/logical=true,synthetic=true,txnID=true-16       0.00
```
  • Loading branch information
nvanbenschoten committed Jan 5, 2021
1 parent 09ccfed commit e70f26e
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions pkg/kv/kvserver/tscache/interval_skl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1381,3 +1381,44 @@ func randRange(rng *rand.Rand, slots int) (from, middle, to []byte) {
func randRangeOpt(rng *rand.Rand) rangeOptions {
return rangeOptions(rng.Intn(int(excludeFrom|excludeTo) + 1))
}

func BenchmarkIntervalSklDecodeValue(b *testing.B) {
runBenchWithVals(b, func(b *testing.B, val cacheValue) {
var arr [encodedValSize]byte
enc := encodeValue(arr[:0], val)
for i := 0; i < b.N; i++ {
_, _ = decodeValue(enc)
}
})
}

func BenchmarkIntervalSklEncodeValue(b *testing.B) {
runBenchWithVals(b, func(b *testing.B, val cacheValue) {
var arr [encodedValSize]byte
for i := 0; i < b.N; i++ {
_ = encodeValue(arr[:0], val)
}
})
}

func runBenchWithVals(b *testing.B, fn func(*testing.B, cacheValue)) {
for _, withLogical := range []bool{false, true} {
for _, withSynthetic := range []bool{false, true} {
for _, withTxnID := range []bool{false, true} {
var val cacheValue
val.ts.WallTime = 15
if withLogical {
val.ts.Logical = 10
}
if withSynthetic {
val.ts.Synthetic = true
}
if withTxnID {
val.txnID = uuid.MakeV4()
}
name := fmt.Sprintf("logical=%t,synthetic=%t,txnID=%t", withLogical, withSynthetic, withTxnID)
b.Run(name, func(b *testing.B) { fn(b, val) })
}
}
}
}

0 comments on commit e70f26e

Please sign in to comment.