Skip to content

Commit e882a72

Browse files
document how the benchmark was produced and add python script used
1 parent 2731e7e commit e882a72

File tree

3 files changed

+6527
-6
lines changed

3 files changed

+6527
-6
lines changed

benches/decompress_sink.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use bencher::{benchmark_group, benchmark_main};
44

55
use std::fs;
6-
use std::io::prelude::*;
6+
use std::io::{self, prelude::*};
77
use std::path::Path;
88

99
use bencher::Bencher;
@@ -13,7 +13,14 @@ use zip::read::ZipFile;
1313
use zip::unstable::read::streaming::StreamingArchive;
1414
use zip::{result::ZipResult, ZipArchive};
1515

16-
/* This contains the compressed text of King Lear from Project Gutenberg, in the public domain. */
16+
/* This contains the compressed text of King Lear from Project Gutenberg, in the public domain.
17+
* It contains the text of King Lear in multiple formats:
18+
* 1. Stored (uncompressed)
19+
* 2. Deflated (compresslevel=9)
20+
* 3. Bzip2 (compresslevel=9)
21+
* It contains 50 of each, with 150 entries total. This is generated by the script
22+
* tests/data/generate-king-lear-zip.py.
23+
*/
1724
fn get_test_data() -> ZipResult<ZipArchive<fs::File>> {
1825
let path = Path::new(env!("CARGO_MANIFEST_DIR")).join("tests/data/king-lear-compressed.zip");
1926
let file = fs::File::open(path)?;
@@ -29,7 +36,7 @@ fn write_entry_to_sink_generic(bench: &mut Bencher) {
2936
bench.iter(|| {
3037
for i in 0..archive.len() {
3138
let mut f = archive.by_index_generic(i).unwrap();
32-
std::io::copy(&mut f, &mut std::io::sink()).unwrap();
39+
io::copy(&mut f, &mut io::sink()).unwrap();
3340
}
3441
})
3542
});
@@ -44,7 +51,7 @@ fn write_entry_to_sink_standard(bench: &mut Bencher) {
4451
bench.iter(|| {
4552
for i in 0..archive.len() {
4653
let mut f = archive.by_index(i).unwrap();
47-
std::io::copy(&mut f, &mut std::io::sink()).unwrap();
54+
io::copy(&mut f, &mut io::sink()).unwrap();
4855
}
4956
})
5057
});
@@ -63,7 +70,7 @@ fn write_stream_to_sink_generic(bench: &mut Bencher) {
6370
let mut stream_zip = StreamingArchive::new(&mut reader);
6471

6572
while let Some(mut file) = stream_zip.next_entry().unwrap() {
66-
std::io::copy(&mut file, &mut std::io::sink()).unwrap();
73+
io::copy(&mut file, &mut io::sink()).unwrap();
6774
}
6875
while stream_zip.next_metadata_entry().unwrap().is_some() {}
6976
})
@@ -77,7 +84,7 @@ fn write_stream_to_sink_standard(bench: &mut Bencher) {
7784
struct V;
7885
impl ZipStreamVisitor for V {
7986
fn visit_file(&mut self, file: &mut ZipFile) -> ZipResult<()> {
80-
std::io::copy(file, &mut std::io::sink())?;
87+
io::copy(file, &mut io::sink())?;
8188
Ok(())
8289
}
8390
fn visit_additional_metadata(

0 commit comments

Comments
 (0)