-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbinarylruarray_bench_test.go
77 lines (74 loc) · 1.64 KB
/
binarylruarray_bench_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package k2tree
import (
"fmt"
"testing"
)
var lruBitArrayTypes []bitArrayType = []bitArrayType{
{
create: func() bitarray {
return &sliceArray{}
},
name: "Base",
},
{
create: func() bitarray {
return newBinaryLRUIndex(&sliceArray{}, 64)
},
name: "LRU64",
},
{
create: func() bitarray {
return newBinaryLRUIndex(&sliceArray{}, 128)
},
name: "LRU128",
},
{
create: func() bitarray {
return newBinaryLRUIndex(&sliceArray{}, 512)
},
name: "LRU512",
},
//{
//create: func() bitarray {
//return newBinaryLRUIndex(newPagedSliceArray(128*1024), 128)
//},
//name: "LRU128Paged128kb",
//},
//{
//create: func() bitarray {
//return newBinaryLRUIndex(newPagedSliceArray(1024*1024*8), 128)
//},
//name: "LRU128Paged1MB",
//},
//{
//create: func() bitarray {
//return newBinaryLRUIndex(newPagedSliceArray(1024*1024*8), 512)
//},
//name: "LRU512Paged1MB",
//},
}
func BenchmarkDetermineLRUCacheDistance(b *testing.B) {
b.Skip("To determine a good value for DefaultLRUCacheDistance, run this function")
for _, k2config := range testK2Configs {
for _, bitarrayt := range lruBitArrayTypes {
// i is the power of 2 of the size of the cache distance
for i := 4; i < 13; i++ {
b.Run(fmt.Sprint(k2config.name, bitarrayt.name, "-", 1<<i), func(b *testing.B) {
for i := 0; i < b.N; i++ {
k2, err := newK2Tree(bitarrayt.create, k2config.config)
if err != nil {
b.Fatal(err)
}
if v, ok := k2.tbits.(*binaryLRUIndex); ok {
v.cacheDistance = 1 << i
}
populateIncrementalTree(1000000, k2, false)
}
})
if bitarrayt.name == "Base" {
break
}
}
}
}
}