(b *testing.B, file, password string, optimised bool)
| 565 | } |
| 566 | |
| 567 | func benchmarkArchive(b *testing.B, file, password string, optimised bool) { |
| 568 | b.Helper() |
| 569 | |
| 570 | h := crc32.NewIEEE() |
| 571 | |
| 572 | for range b.N { |
| 573 | r, err := sevenzip.OpenReaderWithPassword(filepath.Join("testdata", file), password) |
| 574 | if err != nil { |
| 575 | b.Fatal(err) |
| 576 | } |
| 577 | |
| 578 | var once sync.Once |
| 579 | |
| 580 | f := func() { |
| 581 | if err := r.Close(); err != nil { |
| 582 | b.Fatal(err) |
| 583 | } |
| 584 | } |
| 585 | |
| 586 | defer once.Do(f) |
| 587 | |
| 588 | if err := extractArchive(b, &r.Reader, -1, h, reader, optimised); err != nil { |
| 589 | b.Fatal(err) |
| 590 | } |
| 591 | |
| 592 | once.Do(f) |
| 593 | } |
| 594 | } |
| 595 | |
| 596 | func BenchmarkAES7z(b *testing.B) { |
| 597 | benchmarkArchive(b, "aes7z.7z", testPassword, true) |
no test coverage detected
searching dependent graphs…