MCPcopy Create free account
hub / github.com/prometheus/common / BenchmarkCreateBuildInfo

Function BenchmarkCreateBuildInfo

expfmt/text_create_test.go:592–626  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

590}
591
592func BenchmarkCreateBuildInfo(b *testing.B) {
593 mf := &dto.MetricFamily{
594 Name: proto.String("benchmark_build_info"),
595 Help: proto.String("Test the creation of constant 1-value build_info metric."),
596 Type: dto.MetricType_GAUGE.Enum(),
597 Metric: []*dto.Metric{
598 {
599 Label: []*dto.LabelPair{
600 {
601 Name: proto.String("version"),
602 Value: proto.String("1.2.3"),
603 },
604 {
605 Name: proto.String("revision"),
606 Value: proto.String("2e84f5e4eacdffb574035810305191ff390360fe"),
607 },
608 {
609 Name: proto.String("go_version"),
610 Value: proto.String("1.11.1"),
611 },
612 },
613 Gauge: &dto.Gauge{
614 Value: proto.Float64(1),
615 },
616 },
617 },
618 }
619 out := bytes.NewBuffer(make([]byte, 0, 1024))
620
621 for i := 0; i < b.N; i++ {
622 _, err := MetricFamilyToText(out, mf)
623 require.NoError(b, err)
624 out.Reset()
625 }
626}
627
628func TestCreateError(t *testing.T) {
629 scenarios := []struct {

Callers

nothing calls this directly

Calls 2

MetricFamilyToTextFunction · 0.85
StringMethod · 0.65

Tested by

no test coverage detected