@@ -19,18 +19,15 @@ func generateChunks(b testing.TB, startAt, count, step uint32) []chunk.IterGen {
19
19
return res
20
20
}
21
21
22
- func initMetric (b testing.TB , start , step uint32 ) (schema.MKey , * CCacheMetric ) {
23
- ccm := NewCCacheMetric ()
22
+ func getCCM () (schema.MKey , * CCacheMetric ) {
24
23
mkey , _ := schema .MKeyFromString ("1.12345678901234567890123456789012" )
25
- values := make ([]uint32 , step )
26
- c := getItgen (b , values , start , true )
27
- ccm .Init (mkey , 0 , c )
24
+ ccm := NewCCacheMetric (mkey )
28
25
return mkey , ccm
29
26
}
30
27
31
28
func BenchmarkAddingManyChunksOneByOne (b * testing.B ) {
32
- _ , ccm := initMetric ( b , 10 , 10 )
33
- chunks := generateChunks (b , 20 , uint32 (b .N ), 10 )
29
+ _ , ccm := getCCM ( )
30
+ chunks := generateChunks (b , 10 , uint32 (b .N ), 10 )
34
31
prev := uint32 (1 )
35
32
b .ResetTimer ()
36
33
for _ , chunk := range chunks {
@@ -40,18 +37,18 @@ func BenchmarkAddingManyChunksOneByOne(b *testing.B) {
40
37
}
41
38
42
39
func BenchmarkAddingManyChunksAtOnce (b * testing.B ) {
43
- _ , ccm := initMetric ( b , 10 , 10 )
44
- chunks := generateChunks (b , 20 , uint32 (b .N ), 10 )
40
+ _ , ccm := getCCM ( )
41
+ chunks := generateChunks (b , 10 , uint32 (b .N ), 10 )
45
42
prev := uint32 (1 )
46
43
b .ResetTimer ()
47
44
ccm .AddRange (prev , chunks )
48
45
}
49
46
50
47
func TestAddingChunksOneByOneAndQueryingThem (t * testing.T ) {
51
- mkey , ccm := initMetric ( t , 10 , 10 )
48
+ mkey , ccm := getCCM ( )
52
49
amkey := schema.AMKey {MKey : mkey , Archive : 0 }
53
- chunks := generateChunks (t , 20 , 5 , 10 )
54
- prev := uint32 (10 )
50
+ chunks := generateChunks (t , 10 , 6 , 10 )
51
+ prev := uint32 (1 )
55
52
for _ , chunk := range chunks {
56
53
ccm .Add (prev , chunk )
57
54
prev = chunk .Ts
@@ -72,9 +69,9 @@ func TestAddingChunksOneByOneAndQueryingThem(t *testing.T) {
72
69
}
73
70
}
74
71
func TestAddingChunksAtOnceAndQueryingThem (t * testing.T ) {
75
- mkey , ccm := initMetric ( t , 10 , 10 )
72
+ mkey , ccm := getCCM ( )
76
73
amkey := schema.AMKey {MKey : mkey , Archive : 0 }
77
- chunks := generateChunks (t , 20 , 5 , 10 )
74
+ chunks := generateChunks (t , 10 , 6 , 10 )
78
75
prev := uint32 (10 )
79
76
ccm .AddRange (prev , chunks )
80
77
0 commit comments