MCPcopy
hub / github.com/prometheus/prometheus / BenchmarkBuildV2WriteRequest

Function BenchmarkBuildV2WriteRequest

storage/remote/queue_manager_test.go:1874–1913  ·  view source on GitHub ↗

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

(b *testing.B)

Source from the content-addressed store, hash-verified

1872 | tee ${bench}.txt
1873*/
1874func BenchmarkBuildV2WriteRequest(b *testing.B) {
1875 noopLogger := promslog.NewNopLogger()
1876 bench := func(b *testing.B, batch []timeSeries) {
1877 symbolTable := writev2.NewSymbolTable()
1878 cEnc := compression.NewSyncEncodeBuffer()
1879 seriesBuff := make([]writev2.TimeSeries, len(batch))
1880 for i := range seriesBuff {
1881 seriesBuff[i].Samples = []writev2.Sample{{}}
1882 seriesBuff[i].Exemplars = []writev2.Exemplar{{}}
1883 }
1884 pBuf := []byte{}
1885
1886 totalSize := 0
1887 for b.Loop() {
1888 populateV2TimeSeries(&symbolTable, batch, seriesBuff, true, true, false)
1889 req, _, _, err := buildV2WriteRequest(noopLogger, seriesBuff, symbolTable.Symbols(), &pBuf, nil, cEnc, "snappy")
1890 if err != nil {
1891 b.Fatal(err)
1892 }
1893 totalSize += len(req)
1894 b.ReportMetric(float64(totalSize)/float64(b.N), "compressedSize/op")
1895 }
1896 }
1897
1898 twoBatch := createDummyTimeSeries(2)
1899 tenBatch := createDummyTimeSeries(10)
1900 hundredBatch := createDummyTimeSeries(100)
1901
1902 b.Run("2 instances", func(b *testing.B) {
1903 bench(b, twoBatch)
1904 })
1905
1906 b.Run("10 instances", func(b *testing.B) {
1907 bench(b, tenBatch)
1908 })
1909
1910 b.Run("1k instances", func(b *testing.B) {
1911 bench(b, hundredBatch)
1912 })
1913}
1914
1915func TestDropOldTimeSeries(t *testing.T) {
1916 t.Parallel()

Callers

nothing calls this directly

Calls 6

NewSyncEncodeBufferFunction · 0.92
populateV2TimeSeriesFunction · 0.85
buildV2WriteRequestFunction · 0.85
createDummyTimeSeriesFunction · 0.85
SymbolsMethod · 0.65
RunMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…