| 1118 | } |
| 1119 | |
| 1120 | func BenchmarkGetLabels_SmallSet(b *testing.B) { |
| 1121 | m := prometheus.NewCounterVec(prometheus.CounterOpts{ |
| 1122 | Name: "test", |
| 1123 | ConstLabels: map[string]string{ |
| 1124 | "cluster": "abc", |
| 1125 | }, |
| 1126 | }, []string{"reason", "user"}) |
| 1127 | |
| 1128 | m.WithLabelValues("bad", "user1").Inc() |
| 1129 | m.WithLabelValues("worse", "user1").Inc() |
| 1130 | m.WithLabelValues("worst", "user1").Inc() |
| 1131 | |
| 1132 | m.WithLabelValues("bad", "user2").Inc() |
| 1133 | m.WithLabelValues("worst", "user2").Inc() |
| 1134 | |
| 1135 | m.WithLabelValues("worst", "user3").Inc() |
| 1136 | |
| 1137 | for b.Loop() { |
| 1138 | if _, err := GetLabels(m, map[string]string{"user": "user1", "reason": "worse"}); err != nil { |
| 1139 | b.Fatal(err) |
| 1140 | } |
| 1141 | } |
| 1142 | } |
| 1143 | |
| 1144 | func BenchmarkGetLabels_MediumSet(b *testing.B) { |
| 1145 | m := prometheus.NewCounterVec(prometheus.CounterOpts{ |