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

Function BenchmarkCreateBuildInfo

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

Source from the content-addressed store, hash-verified

457}
458
459func BenchmarkCreateBuildInfo(b *testing.B) {
460 mf := &dto.MetricFamily{
461 Name: proto.String("benchmark_build_info"),
462 Help: proto.String("Test the creation of constant 1-value build_info metric."),
463 Type: dto.MetricType_GAUGE.Enum(),
464 Metric: []*dto.Metric{
465 {
466 Label: []*dto.LabelPair{
467 {
468 Name: proto.String("version"),
469 Value: proto.String("1.2.3"),
470 },
471 {
472 Name: proto.String("revision"),
473 Value: proto.String("2e84f5e4eacdffb574035810305191ff390360fe"),
474 },
475 {
476 Name: proto.String("go_version"),
477 Value: proto.String("1.11.1"),
478 },
479 },
480 Gauge: &dto.Gauge{
481 Value: proto.Float64(1),
482 },
483 },
484 },
485 }
486 out := bytes.NewBuffer(make([]byte, 0, 1024))
487
488 for i := 0; i < b.N; i++ {
489 _, err := MetricFamilyToText(out, mf)
490 if err != nil {
491 b.Fatal(err)
492 }
493 out.Reset()
494 }
495}
496
497func TestCreateError(t *testing.T) {
498 scenarios := []struct {

Callers

nothing calls this directly

Calls 2

MetricFamilyToTextFunction · 0.85
StringMethod · 0.65

Tested by

no test coverage detected