MCPcopy Index your code
hub / github.com/klauspost/compress / BenchmarkRandom10MBEncodeAllFastest

Function BenchmarkRandom10MBEncodeAllFastest

zstd/encoder_test.go:1187–1204  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

1185}
1186
1187func BenchmarkRandom10MBEncodeAllFastest(b *testing.B) {
1188 rng := rand.New(rand.NewSource(1))
1189 data := make([]byte, 10<<20)
1190 rng.Read(data)
1191 enc, _ := NewWriter(nil, WithEncoderLevel(SpeedFastest), WithEncoderConcurrency(2))
1192 defer enc.Close()
1193 dst := enc.EncodeAll(data, nil)
1194 wantSize := len(dst)
1195 b.ResetTimer()
1196 b.ReportAllocs()
1197 b.SetBytes(int64(len(data)))
1198 for i := 0; i < b.N; i++ {
1199 dst := enc.EncodeAll(data, dst[:0])
1200 if len(dst) != wantSize {
1201 b.Fatal(len(dst), "!=", wantSize)
1202 }
1203 }
1204}
1205
1206func BenchmarkRandom4KEncodeAllDefault(b *testing.B) {
1207 rng := rand.New(rand.NewSource(1))

Callers

nothing calls this directly

Calls 7

CloseMethod · 0.95
WithEncoderLevelFunction · 0.85
WithEncoderConcurrencyFunction · 0.85
EncodeAllMethod · 0.80
FatalMethod · 0.80
NewWriterFunction · 0.70
ReadMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…