func BenchmarkParseProtoMap(b *testing.B) {
	b.StopTimer()
	data, err := ioutil.ReadFile("testdata/protobuf")
	if err != nil {
		b.Fatal(err)
	}
	b.StartTimer()
	for i := 0; i < b.N; i++ {
		families := map[string]*dto.MetricFamily{}
		in := bytes.NewReader(data)
		for {
			family := &dto.MetricFamily{}
			if _, err := pbutil.ReadDelimited(in, family); err != nil {
				if err == io.EOF {
					break
				}
				b.Fatal(err)
			}
			families[family.GetName()] = family
		}
	}
}
BenchmarkParseProtoMap is like BenchmarkParseProto but DOES put the parsed
metric family DTOs into a map. This is not happening during Prometheus
ingestion. It is just here to measure the overhead of that map creation and
separate it from the overhead of the text format parsing.
package expfmt
import (
	"bytes"
	"compress/gzip"
	"io"
	"io/ioutil"
	"testing"
	"github.com/matttproud/golang_protobuf_extensions/pbutil"
	dto "github.com/prometheus/client_model/go"
)
var parser TextParser
func BenchmarkParseText(b *testing.B) {
	b.StopTimer()
	data, err := ioutil.ReadFile("testdata/text")
	if err != nil {
		b.Fatal(err)
	}
	b.StartTimer()
	for i := 0; i < b.N; i++ {
		if _, err := parser.TextToMetricFamilies(bytes.NewReader(data)); err != nil {
			b.Fatal(err)
		}
	}
}
func BenchmarkParseTextGzip(b *testing.B) {
	b.StopTimer()
	data, err := ioutil.ReadFile("testdata/text.gz")
	if err != nil {
		b.Fatal(err)
	}
	b.StartTimer()
	for i := 0; i < b.N; i++ {
		in, err := gzip.NewReader(bytes.NewReader(data))
		if err != nil {
			b.Fatal(err)
		}
		if _, err := parser.TextToMetricFamilies(in); err != nil {
			b.Fatal(err)
		}
	}
}
func BenchmarkParseProto(b *testing.B) {
	b.StopTimer()
	data, err := ioutil.ReadFile("testdata/protobuf")
	if err != nil {
		b.Fatal(err)
	}
	b.StartTimer()
	for i := 0; i < b.N; i++ {
		family := &dto.MetricFamily{}
		in := bytes.NewReader(data)
		for {
			family.Reset()
			if _, err := pbutil.ReadDelimited(in, family); err != nil {
				if err == io.EOF {
					break
				}
				b.Fatal(err)
			}
		}
	}
}
func BenchmarkParseProtoGzip(b *testing.B) {
	b.StopTimer()
	data, err := ioutil.ReadFile("testdata/protobuf.gz")
	if err != nil {
		b.Fatal(err)
	}
	b.StartTimer()
	for i := 0; i < b.N; i++ {
		family := &dto.MetricFamily{}
		in, err := gzip.NewReader(bytes.NewReader(data))
		if err != nil {
			b.Fatal(err)
		}
		for {
			family.Reset()
			if _, err := pbutil.ReadDelimited(in, family); err != nil {
				if err == io.EOF {
					break
				}
				b.Fatal(err)
			}
		}
	}
}