MCPcopy Create free account
hub / github.com/prometheus/prometheus / BenchmarkBuildWriteRequest

Function BenchmarkBuildWriteRequest

storage/remote/queue_manager_test.go:1827–1865  ·  view source on GitHub ↗

Recommended CLI invocation(s): * export bench=buildWriteRequest && go test ./storage/remote/... \ -run '^$' -bench '^BenchmarkBuildWriteRequest' \ -benchtime 1s -count 6 -cpu 2 -timeout 999m -benchmem \ | tee ${bench}.txt */

(b *testing.B)

Source from the content-addressed store, hash-verified

1825 | tee ${bench}.txt
1826*/
1827func BenchmarkBuildWriteRequest(b *testing.B) {
1828 noopLogger := promslog.NewNopLogger()
1829 bench := func(b *testing.B, batch []timeSeries) {
1830 cEnc := compression.NewSyncEncodeBuffer()
1831 seriesBuff := make([]prompb.TimeSeries, len(batch))
1832 for i := range seriesBuff {
1833 seriesBuff[i].Samples = []prompb.Sample{{}}
1834 seriesBuff[i].Exemplars = []prompb.Exemplar{{}}
1835 }
1836 pBuf := proto.NewBuffer(nil)
1837
1838 totalSize := 0
1839 for b.Loop() {
1840 populateTimeSeries(batch, seriesBuff, true, true)
1841 req, _, _, err := buildWriteRequest(noopLogger, seriesBuff, nil, pBuf, nil, cEnc, compression.Snappy)
1842 if err != nil {
1843 b.Fatal(err)
1844 }
1845 totalSize += len(req)
1846 b.ReportMetric(float64(totalSize)/float64(b.N), "compressedSize/op")
1847 }
1848 }
1849
1850 twoBatch := createDummyTimeSeries(2)
1851 tenBatch := createDummyTimeSeries(10)
1852 hundredBatch := createDummyTimeSeries(100)
1853
1854 b.Run("2 instances", func(b *testing.B) {
1855 bench(b, twoBatch)
1856 })
1857
1858 b.Run("10 instances", func(b *testing.B) {
1859 bench(b, tenBatch)
1860 })
1861
1862 b.Run("1k instances", func(b *testing.B) {
1863 bench(b, hundredBatch)
1864 })
1865}
1866
1867// Recommended CLI invocation(s):
1868/*

Callers

nothing calls this directly

Calls 5

NewSyncEncodeBufferFunction · 0.92
populateTimeSeriesFunction · 0.85
buildWriteRequestFunction · 0.85
createDummyTimeSeriesFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…