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

Function BenchmarkRandomEncodeAllDefault

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

Source from the content-addressed store, hash-verified

1223}
1224
1225func BenchmarkRandomEncodeAllDefault(b *testing.B) {
1226 rng := rand.New(rand.NewSource(1))
1227 data := make([]byte, 10<<20)
1228 rng.Read(data)
1229 enc, _ := NewWriter(nil, WithEncoderLevel(SpeedDefault), WithEncoderConcurrency(1))
1230 defer enc.Close()
1231 dst := enc.EncodeAll(data, nil)
1232 wantSize := len(dst)
1233 b.ResetTimer()
1234 b.ReportAllocs()
1235 b.SetBytes(int64(len(data)))
1236 for i := 0; i < b.N; i++ {
1237 dst := enc.EncodeAll(data, dst[:0])
1238 if len(dst) != wantSize {
1239 b.Fatal(len(dst), "!=", wantSize)
1240 }
1241 }
1242}
1243
1244func BenchmarkRandom10MBEncoderFastest(b *testing.B) {
1245 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…