@@ -133,7 +133,7 @@ func TestGroupByTagsSingleGroupByName(t *testing.T) {
133
133
getModel ("name1" , sumabc ),
134
134
}
135
135
136
- testGroupByTags ("MultipleSeriesMultipleResultsMultipleNamesMoreTags " , in , out , "sum" , []string {"name" }, nil , t )
136
+ testGroupByTags ("SingleGroupByName " , in , out , "sum" , []string {"name" }, nil , t )
137
137
}
138
138
139
139
func TestGroupByTagsMultipleGroupByName (t * testing.T ) {
@@ -148,7 +148,7 @@ func TestGroupByTagsMultipleGroupByName(t *testing.T) {
148
148
getModel ("name2" , sumcd ),
149
149
}
150
150
151
- testGroupByTags ("MultipleSeriesMultipleResultsMultipleNamesMoreTags " , in , out , "sum" , []string {"name" }, nil , t )
151
+ testGroupByTags ("MultipleGroupByName " , in , out , "sum" , []string {"name" }, nil , t )
152
152
}
153
153
154
154
func TestGroupByTagsMultipleSeriesMissingTag (t * testing.T ) {
@@ -163,7 +163,7 @@ func TestGroupByTagsMultipleSeriesMissingTag(t *testing.T) {
163
163
getModel ("name2;missingTag=;tag1=val1_1" , sumcd ),
164
164
}
165
165
166
- testGroupByTags ("MultipleSeriesMultipleResultsGroupByName " , in , out , "sum" , []string {"tag1" , "name" , "missingTag" }, nil , t )
166
+ testGroupByTags ("MultipleSeriesMissingTag " , in , out , "sum" , []string {"tag1" , "name" , "missingTag" }, nil , t )
167
167
}
168
168
169
169
func TestGroupByTagsAllAggregators (t * testing.T ) {
@@ -257,62 +257,114 @@ func testGroupByTags(name string, in []models.Series, out []models.Series, agg s
257
257
}
258
258
}
259
259
260
- func BenchmarkGroupByTags10k_1NoNulls (b * testing.B ) {
261
- benchmarkGroupByTags (b , 1 , test .RandFloats10k , test .RandFloats10k )
260
+ // Benchmarks:
261
+
262
+ // input series: 1, 10, 100, 1k, 10k, 100k
263
+ // output series: 1, same as input, then if applicable: 10, 100, 1k, 10k
264
+
265
+ // 1 input series
266
+ func BenchmarkGroupByTags1in1out (b * testing.B ) {
267
+ benchmarkGroupByTags (b , 1 , 1 )
268
+ }
269
+
270
+ // 10 input Series
271
+ func BenchmarkGroupByTags10in1out (b * testing.B ) {
272
+ benchmarkGroupByTags (b , 10 , 1 )
273
+ }
274
+
275
+ func BenchmarkGroupByTags10in10out (b * testing.B ) {
276
+ benchmarkGroupByTags (b , 10 , 10 )
277
+ }
278
+
279
+ // 100 input series
280
+ func BenchmarkGroupByTags100in1out (b * testing.B ) {
281
+ benchmarkGroupByTags (b , 100 , 1 )
282
+ }
283
+
284
+ func BenchmarkGroupByTags100in10out (b * testing.B ) {
285
+ benchmarkGroupByTags (b , 100 , 10 )
286
+ }
287
+
288
+ func BenchmarkGroupByTags100in100out (b * testing.B ) {
289
+ benchmarkGroupByTags (b , 100 , 100 )
290
+ }
291
+
292
+ // 1k input series
293
+ func BenchmarkGroupByTags1000in1out (b * testing.B ) {
294
+ benchmarkGroupByTags (b , 1000 , 1 )
295
+ }
296
+
297
+ func BenchmarkGroupByTags1000in10out (b * testing.B ) {
298
+ benchmarkGroupByTags (b , 1000 , 10 )
299
+ }
300
+
301
+ func BenchmarkGroupByTags1000in100out (b * testing.B ) {
302
+ benchmarkGroupByTags (b , 1000 , 100 )
303
+ }
304
+
305
+ func BenchmarkGroupByTags1000in1000out (b * testing.B ) {
306
+ benchmarkGroupByTags (b , 1000 , 1000 )
262
307
}
263
- func BenchmarkGroupByTags10k_10NoNulls (b * testing.B ) {
264
- benchmarkGroupByTags (b , 10 , test .RandFloats10k , test .RandFloats10k )
308
+
309
+ // 10k input series
310
+ func BenchmarkGroupByTags10000in1out (b * testing.B ) {
311
+ benchmarkGroupByTags (b , 10000 , 1 )
265
312
}
266
- func BenchmarkGroupByTags10k_100NoNulls (b * testing.B ) {
267
- benchmarkGroupByTags (b , 100 , test .RandFloats10k , test .RandFloats10k )
313
+
314
+ func BenchmarkGroupByTags10000in10out (b * testing.B ) {
315
+ benchmarkGroupByTags (b , 10000 , 10 )
268
316
}
269
- func BenchmarkGroupByTags10k_1000NoNulls (b * testing.B ) {
270
- benchmarkGroupByTags (b , 1000 , test .RandFloats10k , test .RandFloats10k )
317
+
318
+ func BenchmarkGroupByTags10000in100out (b * testing.B ) {
319
+ benchmarkGroupByTags (b , 10000 , 100 )
271
320
}
272
321
273
- func BenchmarkGroupByTags10k_1SomeSeriesHalfNulls (b * testing.B ) {
274
- benchmarkGroupByTags (b , 1 , test . RandFloats10k , test . RandFloatsWithNulls10k )
322
+ func BenchmarkGroupByTags10000in1000out (b * testing.B ) {
323
+ benchmarkGroupByTags (b , 10000 , 1000 )
275
324
}
276
- func BenchmarkGroupByTags10k_10SomeSeriesHalfNulls (b * testing.B ) {
277
- benchmarkGroupByTags (b , 10 , test .RandFloats10k , test .RandFloatsWithNulls10k )
325
+
326
+ func BenchmarkGroupByTags10000in10000out (b * testing.B ) {
327
+ benchmarkGroupByTags (b , 10000 , 10000 )
278
328
}
279
- func BenchmarkGroupByTags10k_100SomeSeriesHalfNulls (b * testing.B ) {
280
- benchmarkGroupByTags (b , 100 , test .RandFloats10k , test .RandFloatsWithNulls10k )
329
+
330
+ // 100k input series
331
+ func BenchmarkGroupByTags100000in1out (b * testing.B ) {
332
+ benchmarkGroupByTags (b , 100000 , 1 )
281
333
}
282
- func BenchmarkGroupByTags10k_1000SomeSeriesHalfNulls (b * testing.B ) {
283
- benchmarkGroupByTags (b , 1000 , test .RandFloats10k , test .RandFloatsWithNulls10k )
334
+
335
+ func BenchmarkGroupByTags100000in10out (b * testing.B ) {
336
+ benchmarkGroupByTags (b , 100000 , 10 )
284
337
}
285
338
286
- func BenchmarkGroupByTags10k_1AllSeriesHalfNulls (b * testing.B ) {
287
- benchmarkGroupByTags (b , 1 , test . RandFloatsWithNulls10k , test . RandFloatsWithNulls10k )
339
+ func BenchmarkGroupByTags100000in100out (b * testing.B ) {
340
+ benchmarkGroupByTags (b , 100000 , 100 )
288
341
}
289
- func BenchmarkGroupByTags10k_10AllSeriesHalfNulls (b * testing.B ) {
290
- benchmarkGroupByTags (b , 10 , test .RandFloatsWithNulls10k , test .RandFloatsWithNulls10k )
342
+
343
+ func BenchmarkGroupByTags100000in1000out (b * testing.B ) {
344
+ benchmarkGroupByTags (b , 100000 , 1000 )
291
345
}
292
- func BenchmarkGroupByTags10k_100AllSeriesHalfNulls (b * testing.B ) {
293
- benchmarkGroupByTags (b , 100 , test .RandFloatsWithNulls10k , test .RandFloatsWithNulls10k )
346
+
347
+ func BenchmarkGroupByTags100000in10000out (b * testing.B ) {
348
+ benchmarkGroupByTags (b , 100000 , 10000 )
294
349
}
295
- func BenchmarkGroupByTags10k_1000AllSeriesHalfNulls (b * testing.B ) {
296
- benchmarkGroupByTags (b , 1000 , test .RandFloatsWithNulls10k , test .RandFloatsWithNulls10k )
350
+
351
+ func BenchmarkGroupByTags100000in100000out (b * testing.B ) {
352
+ benchmarkGroupByTags (b , 100000 , 100000 )
297
353
}
298
354
299
- func benchmarkGroupByTags (b * testing.B , numSeries int , fn0 , fn1 func () []schema. Point ) {
355
+ func benchmarkGroupByTags (b * testing.B , numInputSeries , numOutputSeries int ) {
300
356
var input []models.Series
301
357
tagValues := []string {"tag1" , "tag2" , "tag3" , "tag4" }
302
- for i := 0 ; i < numSeries ; i ++ {
303
- tags := make (map [string ]string , len (tagValues ))
304
-
305
- for t , tag := range tagValues {
306
- tags [tag ] = strconv .Itoa (t )
307
- }
358
+ for i := 0 ; i < numInputSeries ; i ++ {
308
359
series := models.Series {
309
360
Target : strconv .Itoa (i ),
310
361
}
311
- if i % 1 == 0 {
312
- series .Datapoints = fn0 ()
313
- } else {
314
- series .Datapoints = fn1 ()
362
+
363
+ for _ , tag := range tagValues {
364
+ series .Target += ";" + tag + "=" + strconv .Itoa (i % numOutputSeries )
315
365
}
366
+
367
+ series .Datapoints = test .RandFloats100 ()
316
368
input = append (input , series )
317
369
}
318
370
b .ResetTimer ()
@@ -327,6 +379,16 @@ func benchmarkGroupByTags(b *testing.B, numSeries int, fn0, fn1 func() []schema.
327
379
if err != nil {
328
380
b .Fatalf ("%s" , err )
329
381
}
382
+
383
+ if len (results ) != numOutputSeries {
384
+ b .Fatalf ("Expected %d groups, got %d" , numOutputSeries , len (results ))
385
+ }
386
+
387
+ if true {
388
+ for _ , serie := range results {
389
+ pointSlicePool .Put (serie .Datapoints [:0 ])
390
+ }
391
+ }
330
392
}
331
- b .SetBytes (int64 (numSeries * len (results [0 ].Datapoints ) * 12 ))
393
+ b .SetBytes (int64 (numInputSeries * len (results [0 ].Datapoints ) * 12 ))
332
394
}
0 commit comments