(numSeries int, b *testing.B)
| 81 | } |
| 82 | |
| 83 | func benchmarkSeriesMap(numSeries int, b *testing.B) { |
| 84 | series := makeSeries(numSeries) |
| 85 | sm := make(map[string]int, numSeries) |
| 86 | |
| 87 | b.ReportAllocs() |
| 88 | |
| 89 | for b.Loop() { |
| 90 | for i, s := range series { |
| 91 | sm[LabelsToKeyString(s)] = i |
| 92 | } |
| 93 | |
| 94 | for _, s := range series { |
| 95 | _, ok := sm[LabelsToKeyString(s)] |
| 96 | if !ok { |
| 97 | b.Fatal("element missing") |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | if len(sm) != numSeries { |
| 102 | b.Fatal("the number of series expected:", numSeries, "got:", len(sm)) |
| 103 | } |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | func makeSeries(n int) []labels.Labels { |
| 108 | series := make([]labels.Labels, 0, n) |
no test coverage detected