@@ -77,13 +77,13 @@ func BenchmarkMutes(b *testing.B) {
7777 benchmarkMutes (b , lastRuleMatchesBenchmark (b , 10000 ))
7878 })
7979 b .Run ("10 inhibition rules, 5 sources, 100 inhibiting alerts" , func (b * testing.B ) {
80- benchmarkMutes (b , manySourcesBenchMark (b , 5 , 10 , 100 ))
80+ benchmarkMutes (b , multipleSourcesBenchMark (b , 5 , 10 , 100 ))
8181 })
8282 b .Run ("100 inhibition rules, 10 sources, 1000 inhibiting alerts" , func (b * testing.B ) {
83- benchmarkMutes (b , manySourcesBenchMark (b , 10 , 100 , 1000 ))
83+ benchmarkMutes (b , multipleSourcesBenchMark (b , 10 , 100 , 1000 ))
8484 })
8585 b .Run ("1000 inhibition rules, 20 sources, 100 inhibiting alerts" , func (b * testing.B ) {
86- benchmarkMutes (b , manySourcesBenchMark (b , 20 , 1000 , 1000 ))
86+ benchmarkMutes (b , multipleSourcesBenchMark (b , 20 , 1000 , 1000 ))
8787 })
8888}
8989
@@ -198,7 +198,7 @@ func lastRuleMatchesBenchmark(b *testing.B, n int) benchmarkOptions {
198198 }
199199}
200200
201- func manySourcesBenchMark (b * testing.B , numSources , numInhibitionRules , numInhibitingAlerts int ) benchmarkOptions {
201+ func multipleSourcesBenchMark (b * testing.B , numSources , numInhibitionRules , numInhibitingAlerts int ) benchmarkOptions {
202202 return benchmarkOptions {
203203 n : numInhibitionRules ,
204204 newRuleFunc : func (idx int ) config.InhibitRule {
@@ -219,15 +219,17 @@ func manySourcesBenchMark(b *testing.B, numSources, numInhibitionRules, numInhib
219219 },
220220 newAlertsFunc : func (idx int , _ config.InhibitRule ) []types.Alert {
221221 var alerts []types.Alert
222- for i := 0 ; i < numInhibitingAlerts ; i ++ {
223- alerts = append (alerts , types.Alert {
224- Alert : model.Alert {
225- Labels : model.LabelSet {
226- "src" : model .LabelValue (strconv .Itoa (idx )),
227- "idx" : model .LabelValue (strconv .Itoa (i )),
222+ for src := 0 ; src < numSources ; src ++ {
223+ for i := 0 ; i < numInhibitingAlerts ; i ++ {
224+ alerts = append (alerts , types.Alert {
225+ Alert : model.Alert {
226+ Labels : model.LabelSet {
227+ "src" : model .LabelValue (strconv .Itoa (src )),
228+ "idx" : model .LabelValue (strconv .Itoa (i )),
229+ },
228230 },
229- },
230- })
231+ })
232+ }
231233 }
232234 return alerts
233235 }, benchFunc : func (mutesFunc func (set model.LabelSet ) bool ) error {
0 commit comments