nolint:godot * go test ./tsdb/record/... \ -run '^$' -bench '^BenchmarkEncode_Samples' \ -benchtime 5s -count 6 -cpu 2 -timeout 999m \ | tee encode.txt benchstat -col /version encode.txt */
(b *testing.B)
| 139 | benchstat -col /version encode.txt |
| 140 | */ |
| 141 | func BenchmarkEncode_Samples(b *testing.B) { |
| 142 | for _, ver := range versions { |
| 143 | for _, compr := range compressions { |
| 144 | for _, data := range dataCases { |
| 145 | b.Run(fmt.Sprintf("version=%s/compr=%v/data=%v", ver.name, compr, data), func(b *testing.B) { |
| 146 | var ( |
| 147 | samples = testrecord.GenTestRefSamplesCase(b, data) |
| 148 | enc = record.Encoder{EnableSTStorage: ver.enableST} |
| 149 | buf []byte |
| 150 | cBuf []byte |
| 151 | ) |
| 152 | |
| 153 | cEnc, err := compression.NewEncoder() |
| 154 | require.NoError(b, err) |
| 155 | |
| 156 | // Warm up. |
| 157 | buf = enc.Samples(samples, buf[:0]) |
| 158 | cBuf, _, err = cEnc.Encode(compr, buf, cBuf[:0]) |
| 159 | require.NoError(b, err) |
| 160 | |
| 161 | b.ReportAllocs() |
| 162 | b.ResetTimer() |
| 163 | for b.Loop() { |
| 164 | buf = enc.Samples(samples, buf[:0]) |
| 165 | b.ReportMetric(float64(len(buf)), "B/rec") |
| 166 | |
| 167 | cBuf, _, _ = cEnc.Encode(compr, buf, cBuf[:0]) |
| 168 | b.ReportMetric(float64(len(cBuf)), "B/compressed-rec") |
| 169 | } |
| 170 | }) |
| 171 | } |
| 172 | } |
| 173 | } |
| 174 | } |
| 175 | |
| 176 | //nolint:godot |
| 177 | /* |
nothing calls this directly
no test coverage detected
searching dependent graphs…