aboutsummaryrefslogtreecommitdiff
path: root/vendor/image/benches
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2024-07-19 15:37:58 +0300
committerValentin Popov <valentin@popov.link>2024-07-19 15:37:58 +0300
commita990de90fe41456a23e58bd087d2f107d321f3a1 (patch)
tree15afc392522a9e85dc3332235e311b7d39352ea9 /vendor/image/benches
parent3d48cd3f81164bbfc1a755dc1d4a9a02f98c8ddd (diff)
downloadfparkan-a990de90fe41456a23e58bd087d2f107d321f3a1.tar.xz
fparkan-a990de90fe41456a23e58bd087d2f107d321f3a1.zip
Deleted vendor folder
Diffstat (limited to 'vendor/image/benches')
-rw-r--r--vendor/image/benches/README.md6
-rw-r--r--vendor/image/benches/copy_from.rs14
-rw-r--r--vendor/image/benches/decode.rs109
-rw-r--r--vendor/image/benches/encode.rs134
4 files changed, 0 insertions, 263 deletions
diff --git a/vendor/image/benches/README.md b/vendor/image/benches/README.md
deleted file mode 100644
index 9516f2c..0000000
--- a/vendor/image/benches/README.md
+++ /dev/null
@@ -1,6 +0,0 @@
-# Getting started with benchmarking
-
-To run the benchmarks you need a nightly rust toolchain.
-Then you launch it with
-
- cargo +nightly bench --features=benchmarks
diff --git a/vendor/image/benches/copy_from.rs b/vendor/image/benches/copy_from.rs
deleted file mode 100644
index 37a4af8..0000000
--- a/vendor/image/benches/copy_from.rs
+++ /dev/null
@@ -1,14 +0,0 @@
-use criterion::{black_box, criterion_group, criterion_main, Criterion};
-use image::{GenericImage, ImageBuffer, Rgba};
-
-pub fn bench_copy_from(c: &mut Criterion) {
- let src = ImageBuffer::from_pixel(2048, 2048, Rgba([255u8, 0, 0, 255]));
- let mut dst = ImageBuffer::from_pixel(2048, 2048, Rgba([0u8, 0, 0, 255]));
-
- c.bench_function("copy_from", |b| {
- b.iter(|| dst.copy_from(black_box(&src), 0, 0))
- });
-}
-
-criterion_group!(benches, bench_copy_from);
-criterion_main!(benches);
diff --git a/vendor/image/benches/decode.rs b/vendor/image/benches/decode.rs
deleted file mode 100644
index 3702d69..0000000
--- a/vendor/image/benches/decode.rs
+++ /dev/null
@@ -1,109 +0,0 @@
-use std::{fs, iter, path};
-
-use criterion::{criterion_group, criterion_main, Criterion};
-use image::ImageFormat;
-
-#[derive(Clone, Copy)]
-struct BenchDef {
- dir: &'static [&'static str],
- files: &'static [&'static str],
- format: ImageFormat,
-}
-
-fn load_all(c: &mut Criterion) {
- const BENCH_DEFS: &'static [BenchDef] = &[
- BenchDef {
- dir: &["bmp", "images"],
- files: &[
- "Core_1_Bit.bmp",
- "Core_4_Bit.bmp",
- "Core_8_Bit.bmp",
- "rgb16.bmp",
- "rgb24.bmp",
- "rgb32.bmp",
- "pal4rle.bmp",
- "pal8rle.bmp",
- "rgb16-565.bmp",
- "rgb32bf.bmp",
- ],
- format: ImageFormat::Bmp,
- },
- BenchDef {
- dir: &["gif", "simple"],
- files: &["alpha_gif_a.gif", "sample_1.gif"],
- format: ImageFormat::Gif,
- },
- BenchDef {
- dir: &["hdr", "images"],
- files: &["image1.hdr", "rgbr4x4.hdr"],
- format: ImageFormat::Hdr,
- },
- BenchDef {
- dir: &["ico", "images"],
- files: &[
- "bmp-24bpp-mask.ico",
- "bmp-32bpp-alpha.ico",
- "png-32bpp-alpha.ico",
- "smile.ico",
- ],
- format: ImageFormat::Ico,
- },
- BenchDef {
- dir: &["jpg", "progressive"],
- files: &["3.jpg", "cat.jpg", "test.jpg"],
- format: ImageFormat::Jpeg,
- },
- // TODO: pnm
- // TODO: png
- BenchDef {
- dir: &["tga", "testsuite"],
- files: &["cbw8.tga", "ctc24.tga", "ubw8.tga", "utc24.tga"],
- format: ImageFormat::Tga,
- },
- BenchDef {
- dir: &["tiff", "testsuite"],
- files: &[
- "hpredict.tiff",
- "hpredict_packbits.tiff",
- "mandrill.tiff",
- "rgb-3c-16b.tiff",
- ],
- format: ImageFormat::Tiff,
- },
- BenchDef {
- dir: &["webp", "images"],
- files: &[
- "simple-gray.webp",
- "simple-rgb.webp",
- "vp8x-gray.webp",
- "vp8x-rgb.webp",
- ],
- format: ImageFormat::WebP,
- },
- ];
-
- for bench in BENCH_DEFS {
- bench_load(c, bench);
- }
-}
-
-criterion_group!(benches, load_all);
-criterion_main!(benches);
-
-fn bench_load(c: &mut Criterion, def: &BenchDef) {
- let group_name = format!("load-{:?}", def.format);
- let mut group = c.benchmark_group(&group_name);
- let paths = IMAGE_DIR.iter().chain(def.dir);
-
- for file_name in def.files {
- let path: path::PathBuf = paths.clone().chain(iter::once(file_name)).collect();
- let buf = fs::read(path).unwrap();
- group.bench_function(file_name.to_owned(), |b| {
- b.iter(|| {
- image::load_from_memory_with_format(&buf, def.format).unwrap();
- })
- });
- }
-}
-
-const IMAGE_DIR: [&'static str; 3] = [".", "tests", "images"];
diff --git a/vendor/image/benches/encode.rs b/vendor/image/benches/encode.rs
deleted file mode 100644
index 0ca4b2a..0000000
--- a/vendor/image/benches/encode.rs
+++ /dev/null
@@ -1,134 +0,0 @@
-extern crate criterion;
-
-use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
-use image::{codecs::bmp::BmpEncoder, codecs::jpeg::JpegEncoder, ColorType};
-
-use std::fs::File;
-use std::io::{BufWriter, Seek, SeekFrom, Write};
-
-trait Encoder {
- fn encode_raw(&self, into: &mut Vec<u8>, im: &[u8], dims: u32, color: ColorType);
- fn encode_bufvec(&self, into: &mut Vec<u8>, im: &[u8], dims: u32, color: ColorType);
- fn encode_file(&self, file: &File, im: &[u8], dims: u32, color: ColorType);
-}
-
-#[derive(Clone, Copy)]
-struct BenchDef {
- with: &'static dyn Encoder,
- name: &'static str,
- sizes: &'static [u32],
- colors: &'static [ColorType],
-}
-
-fn encode_all(c: &mut Criterion) {
- const BENCH_DEFS: &'static [BenchDef] = &[
- BenchDef {
- with: &Bmp,
- name: "bmp",
- sizes: &[100u32, 200, 400],
- colors: &[ColorType::L8, ColorType::Rgb8, ColorType::Rgba8],
- },
- BenchDef {
- with: &Jpeg,
- name: "jpeg",
- sizes: &[64u32, 128, 256],
- colors: &[ColorType::L8, ColorType::Rgb8, ColorType::Rgba8],
- },
- ];
-
- for definition in BENCH_DEFS {
- encode_definition(c, definition)
- }
-}
-
-criterion_group!(benches, encode_all);
-criterion_main!(benches);
-
-type BenchGroup<'a> = criterion::BenchmarkGroup<'a, criterion::measurement::WallTime>;
-
-/// Benchmarks encoding a zeroed image.
-///
-/// For compressed formats this is surely not representative of encoding a normal image but it's a
-/// start for benchmarking.
-fn encode_zeroed(group: &mut BenchGroup, with: &dyn Encoder, size: u32, color: ColorType) {
- let bytes = size as usize * usize::from(color.bytes_per_pixel());
- let im = vec![0; bytes * bytes];
-
- group.bench_with_input(
- BenchmarkId::new(format!("zero-{:?}-rawvec", color), size),
- &im,
- |b, image| {
- let mut v = vec![];
- with.encode_raw(&mut v, &im, size, color);
- b.iter(|| with.encode_raw(&mut v, image, size, color));
- },
- );
- group.bench_with_input(
- BenchmarkId::new(format!("zero-{:?}-bufvec", color), size),
- &im,
- |b, image| {
- let mut v = vec![];
- with.encode_raw(&mut v, &im, size, color);
- b.iter(|| with.encode_bufvec(&mut v, image, size, color));
- },
- );
- group.bench_with_input(
- BenchmarkId::new(format!("zero-{:?}-file", color), size),
- &im,
- |b, image| {
- let file = File::create("temp.bmp").unwrap();
- b.iter(|| with.encode_file(&file, image, size, color));
- },
- );
-}
-
-fn encode_definition(criterion: &mut Criterion, def: &BenchDef) {
- let mut group = criterion.benchmark_group(format!("encode-{}", def.name));
-
- for &color in def.colors {
- for &size in def.sizes {
- encode_zeroed(&mut group, def.with, size, color);
- }
- }
-}
-
-struct Bmp;
-
-struct Jpeg;
-
-trait EncoderBase {
- fn encode(&self, into: impl Write, im: &[u8], dims: u32, color: ColorType);
-}
-
-impl<T: EncoderBase> Encoder for T {
- fn encode_raw(&self, into: &mut Vec<u8>, im: &[u8], dims: u32, color: ColorType) {
- into.clear();
- self.encode(into, im, dims, color);
- }
-
- fn encode_bufvec(&self, into: &mut Vec<u8>, im: &[u8], dims: u32, color: ColorType) {
- into.clear();
- let buf = BufWriter::new(into);
- self.encode(buf, im, dims, color);
- }
-
- fn encode_file(&self, mut file: &File, im: &[u8], dims: u32, color: ColorType) {
- file.seek(SeekFrom::Start(0)).unwrap();
- let buf = BufWriter::new(file);
- self.encode(buf, im, dims, color);
- }
-}
-
-impl EncoderBase for Bmp {
- fn encode(&self, mut into: impl Write, im: &[u8], size: u32, color: ColorType) {
- let mut x = BmpEncoder::new(&mut into);
- x.encode(im, size, size, color).unwrap();
- }
-}
-
-impl EncoderBase for Jpeg {
- fn encode(&self, mut into: impl Write, im: &[u8], size: u32, color: ColorType) {
- let mut x = JpegEncoder::new(&mut into);
- x.encode(im, size, size, color).unwrap();
- }
-}