Skip to content
Closed
Show file tree
Hide file tree
Changes from 161 commits
Commits
Show all changes
162 commits
Select commit Hold shift + click to select a range
d9075e8
use cfg-if in a few places
cosmicexplorer Sep 7, 2023
d0355d2
continue smoothing with feature guards
cosmicexplorer Jul 12, 2023
426a621
add feature info for docs.rs
cosmicexplorer Jul 20, 2023
dc52677
use num_enum to clean up the System type
cosmicexplorer Jul 12, 2023
c1e1272
use displaydoc and thiserror to remove some boilerplate
cosmicexplorer Sep 7, 2023
ff76ca2
make DateTime parsing and error messaging much cleaner
cosmicexplorer Jul 14, 2023
00c6721
avoid making this a breaking change and add a doctest
cosmicexplorer Sep 7, 2023
748728c
finally make zip files Send
cosmicexplorer Sep 22, 2023
b544dc3
make async versions of all the types of streams
cosmicexplorer Sep 22, 2023
d1d83a1
attempt to implement async extract
cosmicexplorer Sep 22, 2023
de84976
impl async unit tests for crc32
cosmicexplorer Sep 22, 2023
95e0919
get a working example of ReadAdapter?
cosmicexplorer Sep 22, 2023
179ea98
Limiter works now!!!
cosmicexplorer Sep 23, 2023
0e93517
get reader works!
cosmicexplorer Sep 23, 2023
8de2093
use TryStreamExt
cosmicexplorer Sep 23, 2023
fee0cb3
add criterion benchmarks that show async is slower lol
cosmicexplorer Sep 23, 2023
24371b3
ok, but at least async reading is much much faster than sync!!
cosmicexplorer Sep 23, 2023
8fc3138
do lots of i/o copying and get very interesting results
cosmicexplorer Sep 23, 2023
d60985c
mess around a little
cosmicexplorer Sep 23, 2023
21a233c
add tmp testproject
cosmicexplorer Sep 23, 2023
c9c4658
make lots of changes at once oops
cosmicexplorer Sep 25, 2023
5f0cbbf
move write head stuff into ops::Drop impls
cosmicexplorer Sep 25, 2023
7faf9bd
add PermitState enum for invariant checking
cosmicexplorer Sep 25, 2023
18db885
add num_enum for easy transposition with atomics
cosmicexplorer Sep 25, 2023
8bd8063
expand Lease::AlreadyTaken
cosmicexplorer Sep 25, 2023
eb02433
remove wrapper mod
cosmicexplorer Sep 25, 2023
315f32e
try to make the ring buffer atomic????
cosmicexplorer Sep 25, 2023
1885103
allow truncating
cosmicexplorer Sep 26, 2023
a6d7a32
initial impl of RingFuturized
cosmicexplorer Sep 26, 2023
239d246
modify Read/WritePermit to remove the lifetime
cosmicexplorer Sep 26, 2023
e75422e
use Ring for tokio!
cosmicexplorer Sep 26, 2023
6f6f901
generalize the ReadAdapter
cosmicexplorer Sep 26, 2023
729f325
refactor RingFuturized via Pusher
cosmicexplorer Sep 26, 2023
11d606e
make everything compile and pass tests again
cosmicexplorer Sep 26, 2023
e61b7d4
fix more stuff
cosmicexplorer Sep 26, 2023
6e76427
changes to tmp
cosmicexplorer Sep 26, 2023
fb4d8fc
try to improve throughput in AsyncIoAdapter
cosmicexplorer Sep 26, 2023
436c688
make extraction like a second faster!!
cosmicexplorer Sep 27, 2023
42ea15b
set permissions on extracted files
cosmicexplorer Sep 27, 2023
012d6a8
split out work to create directories
cosmicexplorer Sep 27, 2023
40023b0
split extraction into several pipelined phases
cosmicexplorer Sep 27, 2023
02890a0
almost on par with sync now!!!!!!
cosmicexplorer Sep 27, 2023
66f0652
another speedup
cosmicexplorer Sep 27, 2023
031b08e
parallelize dir creation
cosmicexplorer Sep 27, 2023
e53ca77
remove unused imports
cosmicexplorer Sep 27, 2023
0a9859a
tiny refactor
cosmicexplorer Sep 27, 2023
609416b
get EXTREMELY close to sync performance!!!
cosmicexplorer Sep 27, 2023
dfde875
fix matching task and we BEAT sync now!!!
cosmicexplorer Sep 27, 2023
da4135e
cleanup
cosmicexplorer Sep 27, 2023
0a2660a
comments
cosmicexplorer Sep 27, 2023
784086c
tiny optimizations to the dir creation phase
cosmicexplorer Sep 27, 2023
013797f
use read_exact() and preallocate because we know exactly how much to …
cosmicexplorer Sep 27, 2023
0c32e9b
reduce PathBuf allocations
cosmicexplorer Sep 27, 2023
391a739
optimize buffering
cosmicexplorer Sep 27, 2023
f3c65c4
write permission to file!
cosmicexplorer Sep 27, 2023
c3f01b1
be more explicit about how we open extraction output files
cosmicexplorer Sep 27, 2023
d38e07f
refactor several things
cosmicexplorer Sep 30, 2023
33a034d
improve benchmarks
cosmicexplorer Sep 30, 2023
3223047
improve tmp harness
cosmicexplorer Sep 30, 2023
bc601d7
tiny improvement
cosmicexplorer Sep 30, 2023
ca7dba5
remove extraneous trait bounds
cosmicexplorer Sep 30, 2023
cc03c68
remove unnecessary macro
cosmicexplorer Sep 30, 2023
dcb71e6
remove a lot of stuff we don't need
cosmicexplorer Sep 30, 2023
c78e598
remove FixedLengthFile
cosmicexplorer Sep 30, 2023
6201f72
remove changes to zipcrypto
cosmicexplorer Sep 30, 2023
4ded289
remove some changes to Cargo.toml
cosmicexplorer Sep 30, 2023
6d65c26
move async stuff to tokio subdir
cosmicexplorer Sep 30, 2023
4315346
clean up Cargo.toml
cosmicexplorer Sep 30, 2023
355cf72
expand async deflate support
cosmicexplorer Sep 30, 2023
9c5f0e3
add BufWriter
cosmicexplorer Oct 1, 2023
ef76c6a
we have a good BufWriter now!
cosmicexplorer Oct 1, 2023
c9dccc5
only one test failure!!!
cosmicexplorer Oct 1, 2023
10653c2
absurd pinning procedures fail to fix test
cosmicexplorer Oct 1, 2023
672c117
reader tests work!
cosmicexplorer Oct 2, 2023
1422278
refactor some tests
cosmicexplorer Oct 2, 2023
ba8868b
propose alternative testing?
cosmicexplorer Oct 2, 2023
a1cc633
remove unused imports
cosmicexplorer Oct 2, 2023
7598b73
nobody knows how to fix this for now lmao
cosmicexplorer Oct 2, 2023
ed65552
DOWN TO ONE TEST FAILURE
cosmicexplorer Oct 2, 2023
6d03139
all tests pass now
cosmicexplorer Oct 2, 2023
4d53091
code suddenly started working
cosmicexplorer Oct 2, 2023
d8bf219
fix up some error messages
cosmicexplorer Oct 2, 2023
9c50a08
switch to normal pin-project crate and remove Unpin bounds!
cosmicexplorer Oct 2, 2023
1ff110a
move away from pin-project in favor of Pin<Box<...>>
cosmicexplorer Oct 5, 2023
0095dec
add extract_simple() method
cosmicexplorer Oct 5, 2023
c6a58e2
writing works?????
cosmicexplorer Oct 5, 2023
ba342bd
clean up some stuff
cosmicexplorer Oct 5, 2023
ba94c94
Merge branch 'use-displaydoc-thiserror' into async-executor
cosmicexplorer Oct 5, 2023
694eb56
Merge branch 'num-enum-system' into async-executor
cosmicexplorer Oct 5, 2023
dc9103f
Merge branch 'use-cfg-if' into async-executor
cosmicexplorer Oct 5, 2023
b421ac2
Merge branch 'fix-datetime-api' into async-executor
cosmicexplorer Oct 5, 2023
2b5c126
add finish_into_readable()
cosmicexplorer Oct 5, 2023
64692bb
add merge_archive
cosmicexplorer Oct 5, 2023
39f10cc
add broken merge_archive benchmark
cosmicexplorer Oct 5, 2023
1a27805
make several things less public
cosmicexplorer Oct 5, 2023
d93919f
add new_append()
cosmicexplorer Oct 5, 2023
917de42
expose Shared and SharedData
cosmicexplorer Oct 5, 2023
aaf4d2f
add is_dir() and unix_mode()
cosmicexplorer Oct 5, 2023
8e0e1d3
fix errors
cosmicexplorer Oct 5, 2023
5e1dae4
add os.rs
cosmicexplorer Oct 5, 2023
193d575
make os submodule
cosmicexplorer Oct 5, 2023
b4a9ea9
add file descriptor validation from tokio-pipe
cosmicexplorer Oct 6, 2023
3cb9dd8
copy_file_range() works????/
cosmicexplorer Oct 6, 2023
f45f8f1
ownership comes into play
cosmicexplorer Oct 6, 2023
c92484e
refactor fd wrappers
cosmicexplorer Oct 6, 2023
7bf627c
flesh out pipe interactions
cosmicexplorer Oct 6, 2023
be22e05
add benchmark which shows copy_file_range EXACTLY the same as sync?
cosmicexplorer Oct 6, 2023
5921729
add copy-file-range
cosmicexplorer Oct 6, 2023
c46d124
clean a lot of stuff up
cosmicexplorer Oct 6, 2023
8ebd379
make central directory parsing faster (?)
cosmicexplorer Oct 6, 2023
d00e547
cleanup
cosmicexplorer Oct 6, 2023
e25c68f
make tmp work by fixing memchr dep
cosmicexplorer Oct 6, 2023
e6a3f78
write_async changes
cosmicexplorer Oct 6, 2023
6047440
check for vectorized write
cosmicexplorer Oct 6, 2023
c9c5811
more cleanup
cosmicexplorer Oct 6, 2023
b8c21ce
streamline local header writing
cosmicexplorer Oct 6, 2023
05d7854
move LocalHeaderBuffer to spec
cosmicexplorer Oct 6, 2023
270b6cd
introduce another wrapper
cosmicexplorer Oct 6, 2023
3d7d49a
buffer more
cosmicexplorer Oct 6, 2023
d7c7026
streamline more
cosmicexplorer Oct 6, 2023
fe3577b
more streamlining
cosmicexplorer Oct 6, 2023
18be9da
more streamlining
cosmicexplorer Oct 6, 2023
25aa63c
more streamlining
cosmicexplorer Oct 6, 2023
3899460
more streamlining
cosmicexplorer Oct 6, 2023
d52920a
vectorize write for more places
cosmicexplorer Oct 6, 2023
3728d4d
cleanup
cosmicexplorer Oct 6, 2023
5b657e1
more streamlining
cosmicexplorer Oct 6, 2023
e85498b
fix endianness
cosmicexplorer Oct 6, 2023
512a833
add static assertion
cosmicexplorer Oct 7, 2023
77e78fe
fix compilation errors
cosmicexplorer Oct 7, 2023
f4957ec
delete some code
cosmicexplorer Oct 8, 2023
cfe9f77
clean up RawArgs a bit
cosmicexplorer Oct 8, 2023
0009b2d
remove tokio-pipe dep
cosmicexplorer Oct 8, 2023
a273b84
fix memchr dep
cosmicexplorer Oct 8, 2023
a4d640b
cleanup
cosmicexplorer Oct 8, 2023
4110282
fix a TERRIBLE bug lmfao
cosmicexplorer Oct 8, 2023
52a5c9b
improve perf of locating the initial zip central directory
cosmicexplorer Oct 8, 2023
9a994c2
avoid dynamic memory allocation when searching for *end* of central d…
cosmicexplorer Oct 8, 2023
c886931
fix a bug and simplify our header parsing a lot
cosmicexplorer Oct 8, 2023
9392044
remove debug statements
cosmicexplorer Oct 8, 2023
1cf3fb9
enable splicing pipes to and from files
cosmicexplorer Oct 10, 2023
5c82074
impl IntoRawFd for MutateInnerOffset
cosmicexplorer Oct 10, 2023
ba6d8d6
slightly improve file splice test
cosmicexplorer Oct 10, 2023
542cda0
test requesting more splice than available
cosmicexplorer Oct 10, 2023
455a942
add test for vectored write impls
cosmicexplorer Oct 10, 2023
35c04c7
clean up buf reader/writer
cosmicexplorer Oct 10, 2023
6af327b
tiny refactor
cosmicexplorer Oct 10, 2023
6d64862
fix bug in merge_archive() -- support nonzero archive_offset
cosmicexplorer Oct 10, 2023
aea5359
add rayon dep
cosmicexplorer Oct 10, 2023
3c2bf8d
tiny fix to doctest
cosmicexplorer Oct 10, 2023
d07a48e
add another rayon usage
cosmicexplorer Oct 10, 2023
87f21bb
fix note
cosmicexplorer Oct 10, 2023
6843d2d
add impl for splitting into files, but tests are broken
cosmicexplorer Oct 10, 2023
1da7060
stop making Limiter impl Seek
cosmicexplorer Oct 11, 2023
d48617c
Revert "stop making Limiter impl Seek"
cosmicexplorer Oct 11, 2023
868b737
add back ring buf impl to prep for async fd impls
cosmicexplorer Oct 16, 2023
9ae3c7d
add very simple fake async impls for fd wrappers
cosmicexplorer Oct 16, 2023
329a309
fix tokio::io::copy test cases
cosmicexplorer Oct 16, 2023
eda9f45
impl Clone for FromGivenOffset
cosmicexplorer Oct 16, 2023
f755697
impl for MutateInnerOffset
cosmicexplorer Oct 17, 2023
952bfc9
Merge remote-tracking branch 'cosmicex/async-executor' into oldpr409
Pr0methean May 1, 2024
049ce91
Merge branch 'master' into oldpr409
Pr0methean May 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 53 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,45 @@ time = { version = "0.3.36", default-features = false }

[dependencies]
aes = { version = "0.8.4", optional = true }
async-stream = { version = "0.3.5", optional = true }
byteorder = "1.5.0"
bzip2 = { version = "0.4.4", optional = true }
chrono = { version = "0.4.38", optional = true }
cfg-if = "1"
constant_time_eq = { version = "0.3.0", optional = true }
crc32fast = "1.4.0"
displaydoc = "0.2.4"
thiserror = "1.0.48"
flate2 = { version = "1.0.28", default-features = false, optional = true }
futures-core = { version = "0.3", optional = true }
futures-util = { version = "0.3", optional = true }
hmac = { version = "0.12.1", optional = true, features = ["reset"] }
indexmap = { version = "2", features = ["rayon"], optional = true }
libc = { version = "0.2.148", optional = true }
num_enum = "0.6.1"
once_cell = { version = "1.18.0", optional = true }
parking_lot = { version = "0.12.1", features = ["arc_lock"], optional = true }
pbkdf2 = { version = "0.12.2", optional = true }
rayon = { version = "1.8.0", optional = true }
sha1 = { version = "0.10.6", optional = true }
static_assertions = { version = "1.1.0", optional = true }
tempfile = { version = "3.8.0", optional = true }
time = { workspace = true, optional = true, features = [
"std",
] }
zstd = { version = "0.13.1", optional = true, default-features = false }
tokio = { version = "1", features = ["rt", "io-util", "sync", "fs", "macros"], optional = true }
tokio-pipe = { git = "https://github.com/cosmicexplorer/tokio-pipe", rev = "c44321ae17b4324a8ccaa4f687a8f68259fdca30", optional = true }
tokio-stream = { version = "0.1.14", optional = true }
zopfli = { version = "0.8.0", optional = true }
deflate64 = { version = "0.1.8", optional = true }
lzma-rs = { version = "0.3.0", optional = true }

[dependencies.memchr2]
version = "2.6.4"
optional = true
package = "memchr"

[target.'cfg(any(all(target_arch = "arm", target_pointer_width = "32"), target_arch = "mips", target_arch = "powerpc"))'.dependencies]
crossbeam-utils = "0.8.19"

Expand All @@ -48,10 +70,15 @@ arbitrary = { version = "1.3.2", features = ["derive"] }

[dev-dependencies]
bencher = "0.1.5"
getrandom = { version = "0.2.14", features = ["js"] }
walkdir = "2.5.0"
criterion = { version = "0.5", features = ["async_tokio"] }
getrandom = "0.2.14"
tempfile = "3.8.0"
time = { workspace = true, features = ["formatting", "macros"] }
anyhow = "1"
tokio = { version = "1", features = ["rt", "rt-multi-thread"] }
tokio-test = "0.4.3"
uuid = { version = "1.4.1", features = ["v4"] }
walkdir = "2.5.0"

[features]
aes-crypto = ["aes", "constant_time_eq", "hmac", "pbkdf2", "sha1"]
chrono = ["chrono/default"]
Expand All @@ -65,6 +92,11 @@ deflate-zlib = ["flate2/zlib", "_deflate-any"]
deflate-zlib-ng = ["flate2/zlib-ng", "_deflate-any"]
deflate-zopfli = ["zopfli", "_deflate-any"]
lzma = ["lzma-rs/stream"]
tokio-async = [
"dep:tokio", "dep:memchr2", "dep:tokio-stream", "dep:tokio-pipe", "dep:parking_lot", "dep:libc", "dep:futures-core",
"dep:futures-util", "dep:async-stream", "dep:indexmap", "dep:once_cell", "dep:static_assertions", "dep:rayon",
"dep:tempfile",
]
unreserved = []
default = [
"aes-crypto",
Expand All @@ -76,6 +108,7 @@ default = [
"lzma",
"time",
"zstd",
"tokio-async"
]

[[bench]]
Expand All @@ -85,3 +118,20 @@ harness = false
[[bench]]
name = "read_metadata"
harness = false

[[bench]]
name = "extract"
harness = false

# [[bench]]
# name = "merge_archive"
# harness = false

[profile.release]
strip = false
debug = true
# lto = true

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
221 changes: 221 additions & 0 deletions benches/extract.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,221 @@
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion, Throughput};

use std::io::Cursor;
use std::path::{Path, PathBuf};
use std::pin::Pin;
use std::sync::Arc;
use std::time::Duration;

use getrandom::getrandom;
use once_cell::sync::Lazy;
use tempfile::tempdir;
use tokio::{fs, io, runtime::Runtime};
use uuid::Uuid;

use zip::{result::ZipResult, write::FileOptions, ZipWriter};

fn generate_random_archive(
num_entries: usize,
entry_size: usize,
options: FileOptions,
) -> ZipResult<Cursor<Box<[u8]>>> {
use std::io::Write;

let buf = Cursor::new(Vec::new());
let mut zip = ZipWriter::new(buf);

let mut bytes = vec![0u8; entry_size];
for i in 0..num_entries {
let name = format!("random{}.dat", i);
zip.start_file(name, options)?;
getrandom(&mut bytes).unwrap();
zip.write_all(&bytes)?;
}

let buf = zip.finish()?.into_inner();

Ok(Cursor::new(buf.into_boxed_slice()))
}

static BIG_ARCHIVE_PATH: Lazy<PathBuf> =
Lazy::new(|| Path::new(env!("CARGO_MANIFEST_DIR")).join("benches/target.zip"));

static SMALL_ARCHIVE_PATH: Lazy<PathBuf> =
Lazy::new(|| Path::new(env!("CARGO_MANIFEST_DIR")).join("benches/small-target.zip"));

const NUM_ENTRIES: usize = 1_000;
const ENTRY_SIZE: usize = 10_000;

pub fn bench_io(c: &mut Criterion) {
let rt = Runtime::new().unwrap();

let mut group = c.benchmark_group("io");

let options = FileOptions::default().compression_method(zip::CompressionMethod::Deflated);

let gen_td = tempdir().unwrap();
let random_path = gen_td.path().join("random.zip");
std::io::copy(
&mut generate_random_archive(NUM_ENTRIES, ENTRY_SIZE, options).unwrap(),
&mut std::fs::File::create(&random_path).unwrap(),
)
.unwrap();

for (path, desc, n) in [
(&*BIG_ARCHIVE_PATH, "big archive", Some(30)),
(&*SMALL_ARCHIVE_PATH, "small archive", None),
(&random_path, "random archive", None),
] {
let len = std::fs::metadata(&path).unwrap().len() as usize;
let id = format!("{}({} bytes)", desc, len);

group.throughput(Throughput::Bytes(len as u64));

if let Some(n) = n {
group.sample_size(n);
}

group.bench_function(BenchmarkId::new(&id, "<copy_file_range>"), |b| {
use zip::tokio::os::copy_file_range::*;

let td = tempdir().unwrap();
b.to_async(&rt).iter(|| async {
let sync_handle = std::fs::File::open(path).unwrap();
let mut src = MutateInnerOffset::new(sync_handle, Role::Readable).unwrap();
let mut src = Pin::new(&mut src);

let cur_name = format!("{}.zip", Uuid::new_v4());
let tf = td.path().join(cur_name);
let out = std::fs::File::create(tf).unwrap();
let mut dst = MutateInnerOffset::new(out, Role::Writable).unwrap();
let mut dst = Pin::new(&mut dst);

let written = copy_file_range(src, dst, len).await.unwrap();
assert_eq!(written, len);
});
});

group.bench_function(BenchmarkId::new(&id, "<async copy_buf>"), |b| {
let td = tempdir().unwrap();
b.to_async(&rt).iter(|| async {
let handle = fs::File::open(path).await.unwrap();
let mut buf_handle = io::BufReader::with_capacity(len, handle);

let cur_name = format!("{}.zip", Uuid::new_v4());
let tf = td.path().join(cur_name);

let mut out = fs::File::create(tf).await.unwrap();
assert_eq!(
len as u64,
io::copy_buf(&mut buf_handle, &mut out).await.unwrap()
);
});
});

group.bench_function(BenchmarkId::new(&id, "<async copy (no buf)>"), |b| {
let td = tempdir().unwrap();
b.to_async(&rt).iter(|| async {
let mut handle = fs::File::open(path).await.unwrap();

let cur_name = format!("{}.zip", Uuid::new_v4());
let tf = td.path().join(cur_name);

let mut out = fs::File::create(tf).await.unwrap();
assert_eq!(len as u64, io::copy(&mut handle, &mut out).await.unwrap());
});
});

group.bench_function(BenchmarkId::new(&id, "<sync copy (no buf)>"), |b| {
let td = tempdir().unwrap();
b.iter(|| {
let mut sync_handle = std::fs::File::open(path).unwrap();

let cur_name = format!("{}.zip", Uuid::new_v4());
let tf = td.path().join(cur_name);

let mut out = std::fs::File::create(tf).unwrap();
assert_eq!(
len as u64,
/* NB: this doesn't use copy_buf like the async case, because std::io has no
* corresponding function, and using an std::io::BufReader wrapper actually
* hurts perf by a lot!! */
std::io::copy(&mut sync_handle, &mut out).unwrap()
);
});
});
}
}

pub fn bench_extract(c: &mut Criterion) {
let rt = Runtime::new().unwrap();
let mut group = c.benchmark_group("extract");

let options = FileOptions::default().compression_method(zip::CompressionMethod::Deflated);

let gen_td = tempdir().unwrap();
let random_path = gen_td.path().join("random.zip");
std::io::copy(
&mut generate_random_archive(NUM_ENTRIES, ENTRY_SIZE, options).unwrap(),
&mut std::fs::File::create(&random_path).unwrap(),
)
.unwrap();

for (path, desc, n, t) in [
(
&*BIG_ARCHIVE_PATH,
"big archive",
Some(10),
Some(Duration::from_secs(10)),
),
(&*SMALL_ARCHIVE_PATH, "small archive", None, None),
(&random_path, "random archive", None, None),
] {
let len = std::fs::metadata(&path).unwrap().len() as usize;
let id = format!("{}({} bytes)", desc, len);

group.throughput(Throughput::Bytes(len as u64));

if let Some(n) = n {
group.sample_size(n);
}
if let Some(t) = t {
group.measurement_time(t);
}

group.bench_function(BenchmarkId::new(&id, "<async extract()>"), |b| {
let td = tempdir().unwrap();
b.to_async(&rt).iter(|| async {
let out_dir = Arc::new(td.path().to_path_buf());
let handle = fs::File::open(path).await.unwrap();
let mut zip = zip::tokio::read::ZipArchive::new(Box::pin(handle))
.await
.unwrap();
Pin::new(&mut zip).extract(out_dir).await.unwrap();
})
});

group.bench_function(BenchmarkId::new(&id, "<async extract_simple()>"), |b| {
let td = tempdir().unwrap();
b.to_async(&rt).iter(|| async {
let out_dir = Arc::new(td.path().to_path_buf());
let handle = fs::File::open(path).await.unwrap();
let mut zip = zip::tokio::read::ZipArchive::new(Box::pin(handle))
.await
.unwrap();
Pin::new(&mut zip).extract_simple(out_dir).await.unwrap();
})
});

group.bench_function(BenchmarkId::new(&id, "<sync extract()>"), |b| {
let td = tempdir().unwrap();
b.iter(|| {
let sync_handle = std::fs::File::open(path).unwrap();
let mut zip = zip::read::ZipArchive::new(sync_handle).unwrap();
zip.extract(td.path()).unwrap();
})
});
}
}

criterion_group!(benches, bench_io, bench_extract);
criterion_main!(benches);
Loading