(b *testing.B)
| 1417 | } |
| 1418 | |
| 1419 | func BenchmarkDecoder_DecoderNewSomeRead(b *testing.B) { |
| 1420 | var buf [1 << 20]byte |
| 1421 | bench := func(name string, b *testing.B, opts []DOption, in *os.File) { |
| 1422 | b.Helper() |
| 1423 | b.Run(name, func(b *testing.B) { |
| 1424 | //b.ReportAllocs() |
| 1425 | b.ResetTimer() |
| 1426 | var heapTotal int64 |
| 1427 | var m runtime.MemStats |
| 1428 | for i := 0; i < b.N; i++ { |
| 1429 | runtime.GC() |
| 1430 | runtime.ReadMemStats(&m) |
| 1431 | heapTotal -= int64(m.HeapInuse) |
| 1432 | _, err := in.Seek(io.SeekStart, 0) |
| 1433 | if err != nil { |
| 1434 | b.Fatal(err) |
| 1435 | } |
| 1436 | |
| 1437 | dec, err := NewReader(in, opts...) |
| 1438 | if err != nil { |
| 1439 | b.Fatal(err) |
| 1440 | } |
| 1441 | // Read 16 MB |
| 1442 | _, err = io.CopyBuffer(io.Discard, io.LimitReader(dec, 16<<20), buf[:]) |
| 1443 | if err != nil { |
| 1444 | b.Fatal(err) |
| 1445 | } |
| 1446 | runtime.GC() |
| 1447 | runtime.ReadMemStats(&m) |
| 1448 | heapTotal += int64(m.HeapInuse) |
| 1449 | |
| 1450 | dec.Close() |
| 1451 | } |
| 1452 | b.ReportMetric(float64(heapTotal)/float64(b.N), "b/op") |
| 1453 | }) |
| 1454 | } |
| 1455 | files := []string{"testdata/000002.map.win32K.zst", "testdata/000002.map.win1MB.zst", "testdata/000002.map.win8MB.zst"} |
| 1456 | for _, file := range files { |
| 1457 | if !strings.HasSuffix(file, ".zst") { |
| 1458 | continue |
| 1459 | } |
| 1460 | r, err := os.Open(file) |
| 1461 | if err != nil { |
| 1462 | b.Fatal(err) |
| 1463 | } |
| 1464 | defer r.Close() |
| 1465 | |
| 1466 | b.Run(file, func(b *testing.B) { |
| 1467 | bench("stream-single", b, []DOption{WithDecodeBuffersBelow(0), WithDecoderConcurrency(1)}, r) |
| 1468 | bench("stream-single-himem", b, []DOption{WithDecodeBuffersBelow(0), WithDecoderConcurrency(1), WithDecoderLowmem(false)}, r) |
| 1469 | }) |
| 1470 | } |
| 1471 | } |
| 1472 | |
| 1473 | func BenchmarkDecoder_DecodeAll(b *testing.B) { |
| 1474 | zr := testCreateZipReader("testdata/benchdecoder.zip", b) |
nothing calls this directly
no test coverage detected
searching dependent graphs…