MCPcopy
hub / github.com/klauspost/compress / Benchmark_seqdec_execute

Function Benchmark_seqdec_execute

zstd/seqdec_test.go:459–513  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

457}
458
459func Benchmark_seqdec_execute(b *testing.B) {
460 zr := testCreateZipReader("testdata/seqs.zip", b)
461 tb := b
462 for _, tt := range zr.File {
463 var ref testSequence
464 if !ref.parse(tt.Name) {
465 tb.Skip("unable to parse:", tt.Name)
466 }
467 r, err := tt.Open()
468 if err != nil {
469 tb.Error(err)
470 return
471 }
472
473 seqData, err := io.ReadAll(r)
474 if err != nil {
475 tb.Error(err)
476 return
477 }
478 var buf = bytes.NewBuffer(seqData)
479 s := readDecoders(tb, buf, ref)
480 seqs := make([]seqVals, ref.n)
481
482 fatalIf := func(err error) {
483 if err != nil {
484 b.Fatal(err)
485 }
486 }
487 fatalIf(s.br.init(buf.Bytes()))
488 fatalIf(s.litLengths.init(s.br))
489 fatalIf(s.offsets.init(s.br))
490 fatalIf(s.matchLengths.init(s.br))
491
492 fatalIf(s.decode(seqs))
493 hist := make([]byte, ref.win)
494 lits := s.literals
495
496 b.Run(tt.Name, func(b *testing.B) {
497 b.ReportAllocs()
498 b.SetBytes(int64(s.seqSize))
499 b.ResetTimer()
500 t := time.Now()
501 decoded := 0
502 for i := 0; i < b.N; i++ {
503 s.literals = lits
504 if len(s.out) > 0 {
505 s.out = s.out[:0]
506 }
507 fatalIf(s.execute(seqs, hist))
508 decoded += ref.n
509 }
510 b.ReportMetric(float64(decoded)/time.Since(t).Seconds(), "seq/s")
511 })
512 }
513}
514
515func Benchmark_seqdec_decodeSync(b *testing.B) {
516 zr := testCreateZipReader("testdata/seqs.zip", b)

Callers

nothing calls this directly

Calls 11

parseMethod · 0.95
testCreateZipReaderFunction · 0.85
readDecodersFunction · 0.85
SkipMethod · 0.80
FatalMethod · 0.80
executeMethod · 0.80
BytesMethod · 0.65
OpenMethod · 0.45
ErrorMethod · 0.45
initMethod · 0.45
decodeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…