Skip to content

Commit

Permalink
Clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
kornelski authored and andrews05 committed Jan 1, 2025
1 parent 8270c6a commit a72bc94
Show file tree
Hide file tree
Showing 18 changed files with 148 additions and 208 deletions.
123 changes: 32 additions & 91 deletions benches/filters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,24 @@ extern crate test;

use std::path::PathBuf;

use oxipng::{internal_tests::*, *};
use oxipng::internal_tests::*;
use oxipng::*;
use test::Bencher;

#[bench]
fn filters_16_bits_filter_0(b: &mut Bencher) {
let input = test::black_box(PathBuf::from("tests/files/rgb_16_should_be_rgb_16.png"));
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
png.raw.filter_image(RowFilter::None, false);
});
b.iter(|| png.raw.filter_image(RowFilter::None, false));
}

#[bench]
fn filters_8_bits_filter_0(b: &mut Bencher) {
let input = test::black_box(PathBuf::from("tests/files/rgb_8_should_be_rgb_8.png"));
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
png.raw.filter_image(RowFilter::None, false);
});
b.iter(|| png.raw.filter_image(RowFilter::None, false));
}

#[bench]
Expand All @@ -35,9 +32,7 @@ fn filters_4_bits_filter_0(b: &mut Bencher) {
));
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
png.raw.filter_image(RowFilter::None, false);
});
b.iter(|| png.raw.filter_image(RowFilter::None, false));
}

#[bench]
Expand All @@ -47,9 +42,7 @@ fn filters_2_bits_filter_0(b: &mut Bencher) {
));
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
png.raw.filter_image(RowFilter::None, false);
});
b.iter(|| png.raw.filter_image(RowFilter::None, false));
}

#[bench]
Expand All @@ -59,29 +52,23 @@ fn filters_1_bits_filter_0(b: &mut Bencher) {
));
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
png.raw.filter_image(RowFilter::None, false);
});
b.iter(|| png.raw.filter_image(RowFilter::None, false));
}

#[bench]
fn filters_16_bits_filter_1(b: &mut Bencher) {
let input = test::black_box(PathBuf::from("tests/files/rgb_16_should_be_rgb_16.png"));
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
png.raw.filter_image(RowFilter::Sub, false);
});
b.iter(|| png.raw.filter_image(RowFilter::Sub, false));
}

#[bench]
fn filters_8_bits_filter_1(b: &mut Bencher) {
let input = test::black_box(PathBuf::from("tests/files/rgb_8_should_be_rgb_8.png"));
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
png.raw.filter_image(RowFilter::Sub, false);
});
b.iter(|| png.raw.filter_image(RowFilter::Sub, false));
}

#[bench]
Expand All @@ -91,9 +78,7 @@ fn filters_4_bits_filter_1(b: &mut Bencher) {
));
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
png.raw.filter_image(RowFilter::Sub, false);
});
b.iter(|| png.raw.filter_image(RowFilter::Sub, false));
}

#[bench]
Expand All @@ -103,9 +88,7 @@ fn filters_2_bits_filter_1(b: &mut Bencher) {
));
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
png.raw.filter_image(RowFilter::Sub, false);
});
b.iter(|| png.raw.filter_image(RowFilter::Sub, false));
}

#[bench]
Expand All @@ -115,29 +98,23 @@ fn filters_1_bits_filter_1(b: &mut Bencher) {
));
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
png.raw.filter_image(RowFilter::Sub, false);
});
b.iter(|| png.raw.filter_image(RowFilter::Sub, false));
}

#[bench]
fn filters_16_bits_filter_2(b: &mut Bencher) {
let input = test::black_box(PathBuf::from("tests/files/rgb_16_should_be_rgb_16.png"));
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
png.raw.filter_image(RowFilter::Up, false);
});
b.iter(|| png.raw.filter_image(RowFilter::Up, false));
}

#[bench]
fn filters_8_bits_filter_2(b: &mut Bencher) {
let input = test::black_box(PathBuf::from("tests/files/rgb_8_should_be_rgb_8.png"));
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
png.raw.filter_image(RowFilter::Up, false);
});
b.iter(|| png.raw.filter_image(RowFilter::Up, false));
}

#[bench]
Expand All @@ -147,9 +124,7 @@ fn filters_4_bits_filter_2(b: &mut Bencher) {
));
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
png.raw.filter_image(RowFilter::Up, false);
});
b.iter(|| png.raw.filter_image(RowFilter::Up, false));
}

#[bench]
Expand All @@ -159,9 +134,7 @@ fn filters_2_bits_filter_2(b: &mut Bencher) {
));
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
png.raw.filter_image(RowFilter::Up, false);
});
b.iter(|| png.raw.filter_image(RowFilter::Up, false));
}

#[bench]
Expand All @@ -171,29 +144,23 @@ fn filters_1_bits_filter_2(b: &mut Bencher) {
));
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
png.raw.filter_image(RowFilter::Up, false);
});
b.iter(|| png.raw.filter_image(RowFilter::Up, false));
}

#[bench]
fn filters_16_bits_filter_3(b: &mut Bencher) {
let input = test::black_box(PathBuf::from("tests/files/rgb_16_should_be_rgb_16.png"));
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
png.raw.filter_image(RowFilter::Average, false);
});
b.iter(|| png.raw.filter_image(RowFilter::Average, false));
}

#[bench]
fn filters_8_bits_filter_3(b: &mut Bencher) {
let input = test::black_box(PathBuf::from("tests/files/rgb_8_should_be_rgb_8.png"));
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
png.raw.filter_image(RowFilter::Average, false);
});
b.iter(|| png.raw.filter_image(RowFilter::Average, false));
}

#[bench]
Expand All @@ -203,9 +170,7 @@ fn filters_4_bits_filter_3(b: &mut Bencher) {
));
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
png.raw.filter_image(RowFilter::Average, false);
});
b.iter(|| png.raw.filter_image(RowFilter::Average, false));
}

#[bench]
Expand All @@ -215,9 +180,7 @@ fn filters_2_bits_filter_3(b: &mut Bencher) {
));
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
png.raw.filter_image(RowFilter::Average, false);
});
b.iter(|| png.raw.filter_image(RowFilter::Average, false));
}

#[bench]
Expand All @@ -227,29 +190,23 @@ fn filters_1_bits_filter_3(b: &mut Bencher) {
));
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
png.raw.filter_image(RowFilter::Average, false);
});
b.iter(|| png.raw.filter_image(RowFilter::Average, false));
}

#[bench]
fn filters_16_bits_filter_4(b: &mut Bencher) {
let input = test::black_box(PathBuf::from("tests/files/rgb_16_should_be_rgb_16.png"));
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
png.raw.filter_image(RowFilter::Paeth, false);
});
b.iter(|| png.raw.filter_image(RowFilter::Paeth, false));
}

#[bench]
fn filters_8_bits_filter_4(b: &mut Bencher) {
let input = test::black_box(PathBuf::from("tests/files/rgb_8_should_be_rgb_8.png"));
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
png.raw.filter_image(RowFilter::Paeth, false);
});
b.iter(|| png.raw.filter_image(RowFilter::Paeth, false));
}

#[bench]
Expand All @@ -259,9 +216,7 @@ fn filters_4_bits_filter_4(b: &mut Bencher) {
));
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
png.raw.filter_image(RowFilter::Paeth, false);
});
b.iter(|| png.raw.filter_image(RowFilter::Paeth, false));
}

#[bench]
Expand All @@ -271,9 +226,7 @@ fn filters_2_bits_filter_4(b: &mut Bencher) {
));
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
png.raw.filter_image(RowFilter::Paeth, false);
});
b.iter(|| png.raw.filter_image(RowFilter::Paeth, false));
}

#[bench]
Expand All @@ -283,29 +236,23 @@ fn filters_1_bits_filter_4(b: &mut Bencher) {
));
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
png.raw.filter_image(RowFilter::Paeth, false);
});
b.iter(|| png.raw.filter_image(RowFilter::Paeth, false));
}

#[bench]
fn filters_16_bits_filter_5(b: &mut Bencher) {
let input = test::black_box(PathBuf::from("tests/files/rgb_16_should_be_rgb_16.png"));
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
png.raw.filter_image(RowFilter::MinSum, false);
});
b.iter(|| png.raw.filter_image(RowFilter::MinSum, false));
}

#[bench]
fn filters_8_bits_filter_5(b: &mut Bencher) {
let input = test::black_box(PathBuf::from("tests/files/rgb_8_should_be_rgb_8.png"));
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
png.raw.filter_image(RowFilter::MinSum, false);
});
b.iter(|| png.raw.filter_image(RowFilter::MinSum, false));
}

#[bench]
Expand All @@ -315,9 +262,7 @@ fn filters_4_bits_filter_5(b: &mut Bencher) {
));
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
png.raw.filter_image(RowFilter::MinSum, false);
});
b.iter(|| png.raw.filter_image(RowFilter::MinSum, false));
}

#[bench]
Expand All @@ -327,9 +272,7 @@ fn filters_2_bits_filter_5(b: &mut Bencher) {
));
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
png.raw.filter_image(RowFilter::MinSum, false);
});
b.iter(|| png.raw.filter_image(RowFilter::MinSum, false));
}

#[bench]
Expand All @@ -339,7 +282,5 @@ fn filters_1_bits_filter_5(b: &mut Bencher) {
));
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
png.raw.filter_image(RowFilter::MinSum, false);
});
b.iter(|| png.raw.filter_image(RowFilter::MinSum, false));
}
20 changes: 5 additions & 15 deletions benches/strategies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,47 +13,37 @@ fn filters_minsum(b: &mut Bencher) {
let input = test::black_box(PathBuf::from("tests/files/rgb_8_should_be_rgb_8.png"));
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
png.raw.filter_image(RowFilter::MinSum, false);
});
b.iter(|| png.raw.filter_image(RowFilter::MinSum, false));
}

#[bench]
fn filters_entropy(b: &mut Bencher) {
let input = test::black_box(PathBuf::from("tests/files/rgb_8_should_be_rgb_8.png"));
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
png.raw.filter_image(RowFilter::Entropy, false);
});
b.iter(|| png.raw.filter_image(RowFilter::Entropy, false));
}

#[bench]
fn filters_bigrams(b: &mut Bencher) {
let input = test::black_box(PathBuf::from("tests/files/rgb_8_should_be_rgb_8.png"));
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
png.raw.filter_image(RowFilter::Bigrams, false);
});
b.iter(|| png.raw.filter_image(RowFilter::Bigrams, false));
}

#[bench]
fn filters_bigent(b: &mut Bencher) {
let input = test::black_box(PathBuf::from("tests/files/rgb_8_should_be_rgb_8.png"));
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
png.raw.filter_image(RowFilter::BigEnt, false);
});
b.iter(|| png.raw.filter_image(RowFilter::BigEnt, false));
}

#[bench]
fn filters_brute(b: &mut Bencher) {
let input = test::black_box(PathBuf::from("tests/files/rgb_8_should_be_rgb_8.png"));
let png = PngData::new(&input, &Options::default()).unwrap();

b.iter(|| {
png.raw.filter_image(RowFilter::Brute, false);
});
b.iter(|| png.raw.filter_image(RowFilter::Brute, false));
}
Loading

0 comments on commit a72bc94

Please sign in to comment.