(b *testing.B)
| 688 | } |
| 689 | |
| 690 | func BenchmarkCreateBuildInfo(b *testing.B) { |
| 691 | mf := &dto.MetricFamily{ |
| 692 | Name: proto.String("benchmark_build_info"), |
| 693 | Help: proto.String("Test the creation of constant 1-value build_info metric."), |
| 694 | Type: dto.MetricType_GAUGE.Enum(), |
| 695 | Metric: []*dto.Metric{ |
| 696 | { |
| 697 | Label: []*dto.LabelPair{ |
| 698 | { |
| 699 | Name: proto.String("version"), |
| 700 | Value: proto.String("1.2.3"), |
| 701 | }, |
| 702 | { |
| 703 | Name: proto.String("revision"), |
| 704 | Value: proto.String("2e84f5e4eacdffb574035810305191ff390360fe"), |
| 705 | }, |
| 706 | { |
| 707 | Name: proto.String("go_version"), |
| 708 | Value: proto.String("1.11.1"), |
| 709 | }, |
| 710 | }, |
| 711 | Gauge: &dto.Gauge{ |
| 712 | Value: proto.Float64(1), |
| 713 | }, |
| 714 | }, |
| 715 | }, |
| 716 | } |
| 717 | out := bytes.NewBuffer(make([]byte, 0, 1024)) |
| 718 | |
| 719 | for i := 0; i < b.N; i++ { |
| 720 | _, err := MetricFamilyToText(out, mf) |
| 721 | require.NoError(b, err) |
| 722 | out.Reset() |
| 723 | } |
| 724 | } |
| 725 | |
| 726 | func TestCreateError(t *testing.T) { |
| 727 | scenarios := []struct { |
nothing calls this directly
no test coverage detected
searching dependent graphs…