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)
| 1872 | | tee ${bench}.txt |
| 1873 | */ |
| 1874 | func 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 | |
| 1915 | func TestDropOldTimeSeries(t *testing.T) { |
| 1916 | t.Parallel() |
nothing calls this directly
no test coverage detected
searching dependent graphs…