MCPcopy Create free account
hub / github.com/cortexproject/cortex / BenchmarkGetLabels_SmallSet

Function BenchmarkGetLabels_SmallSet

pkg/util/metrics_helper_test.go:1120–1142  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

1118}
1119
1120func 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
1144func BenchmarkGetLabels_MediumSet(b *testing.B) {
1145 m := prometheus.NewCounterVec(prometheus.CounterOpts{

Callers

nothing calls this directly

Calls 3

GetLabelsFunction · 0.85
LoopMethod · 0.80
IncMethod · 0.45

Tested by

no test coverage detected