Initial vendor packages

Signed-off-by: Valentin Popov <valentin@popov.link>
This commit is contained in:
2024-01-08 01:21:28 +04:00
parent 5ecd8cf2cb
commit 1b6a04ca55
7309 changed files with 2160054 additions and 0 deletions

6
vendor/png/benches/README.md vendored Normal file
View File

@ -0,0 +1,6 @@
# Getting started with benchmarking
To run the benchmarks you need a nightly rust toolchain.
Then you launch it with
rustup run nightly cargo bench --features=benchmarks

38
vendor/png/benches/decoder.rs vendored Normal file
View File

@ -0,0 +1,38 @@
use std::fs;
use criterion::{criterion_group, criterion_main, Criterion, Throughput};
use png::Decoder;
fn load_all(c: &mut Criterion) {
for entry in fs::read_dir("tests/benches/").unwrap().flatten() {
match entry.path().extension() {
Some(st) if st == "png" => {}
_ => continue,
}
let data = fs::read(entry.path()).unwrap();
bench_file(c, data, entry.file_name().into_string().unwrap());
}
}
criterion_group!(benches, load_all);
criterion_main!(benches);
fn bench_file(c: &mut Criterion, data: Vec<u8>, name: String) {
let mut group = c.benchmark_group("decode");
group.sample_size(20);
let decoder = Decoder::new(&*data);
let mut reader = decoder.read_info().unwrap();
let mut image = vec![0; reader.output_buffer_size()];
let info = reader.next_frame(&mut image).unwrap();
group.throughput(Throughput::Bytes(info.buffer_size() as u64));
group.bench_with_input(name, &data, |b, data| {
b.iter(|| {
let decoder = Decoder::new(data.as_slice());
let mut decoder = decoder.read_info().unwrap();
decoder.next_frame(&mut image).unwrap();
})
});
}