Skip to content

Commit

Permalink
Merge #354
Browse files Browse the repository at this point in the history
354: Actually interface with codspeed r=Ogeon a=Ogeon

Forgot this part in #353.

Co-authored-by: Erik Hedvall <[email protected]>
  • Loading branch information
bors[bot] and Ogeon authored Sep 1, 2023
2 parents 3a9fc0e + 24f483c commit 8a2fbfa
Show file tree
Hide file tree
Showing 11 changed files with 57 additions and 44 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
cache-target: release
bins: cargo-codspeed
- name: Build the benchmark target(s)
run: cargo codspeed build -p palette --features wide
run: cargo codspeed build -p benchmarks
- name: Run the benchmarks
uses: CodSpeedHQ/action@v1
with:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: find-crate check
run: cargo clippy -v -p palette --no-default-features --features "std find-crate"
- name: Default check
run: cargo clippy -v --workspace --exclude no_std_test
run: cargo clippy -v -p palette
- name: Test all features
run: cargo test -v -p palette --all-features
- name: Test each feature
Expand Down Expand Up @@ -63,7 +63,7 @@ jobs:
with:
targets: thumbv6m-none-eabi
- name: "Build with #[no_std]"
run: cargo build -v --package no_std_test --features nightly --target thumbv6m-none-eabi
run: cargo build -v -p no_std_test --features nightly --target thumbv6m-none-eabi
miri:
name: Miri tests
runs-on: ubuntu-latest
Expand All @@ -73,9 +73,9 @@ jobs:
with:
components: miri
- name: Unit tests
run: cargo miri test --lib --features "bytemuck" -- -Z unstable-options --report-time
run: cargo miri test -p palette --lib --features "bytemuck" -- -Z unstable-options --report-time
- name: Documentation tests
run: cargo miri test --doc --features "bytemuck" -- -Z unstable-options --report-time
run: cargo miri test -p palette --doc --features "bytemuck" -- -Z unstable-options --report-time

# Refs: https://github.com/rust-lang/crater/blob/9ab6f9697c901c4a44025cf0a39b73ad5b37d198/.github/workflows/bors.yml#L125-L149
#
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- uses: dtolnay/rust-toolchain@nightly
- uses: taiki-e/install-action@cargo-llvm-cov
- name: Collect code coverage
run: cargo +nightly llvm-cov --all-features --workspace --exclude no_std_test --codecov --doctests --output-path codecov.json
run: cargo +nightly llvm-cov --all-features -p palette --codecov --doctests --output-path codecov.json
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ members = [

# Test crates
"no_std_test",
"benchmarks"
]
resolver = "2"
35 changes: 35 additions & 0 deletions benchmarks/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[package]
name = "benchmarks"
version = "0.0.0"
authors = ["Erik Hedvall <[email protected]>"]
exclude = []
description = "Benchmark crate for palette."
repository = "https://github.com/Ogeon/palette"
license = "MIT OR Apache-2.0"
edition = "2018"

[[bench]]
path = "benches/cie.rs"
name = "cie_conversion"
harness = false

[[bench]]
path = "benches/rgb.rs"
name = "rgb_conversion"
harness = false

[[bench]]
path = "benches/matrix.rs"
name = "matrix"
harness = false

[dev-dependencies]
approx = { version = "0.5", default-features = false }
codspeed-criterion-compat = "2.1.0"
criterion = { version = "0.5.1", default-features = false }
csv = "1"
lazy_static = "1"
palette = { path = "../palette", features = ["wide"] }
serde = "1"
serde_derive = "1"
wide = "0.7.3"
1 change: 1 addition & 0 deletions benchmarks/LICENSE-APACHE
1 change: 1 addition & 0 deletions benchmarks/LICENSE-MIT
9 changes: 4 additions & 5 deletions palette/benches/cie.rs → benchmarks/benches/cie.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use codspeed_criterion_compat::{black_box, criterion_group, criterion_main, Criterion};
use palette::convert::FromColorUnclamped;
use palette::{Lab, Lch, Xyz, Yxy};

#[path = "../tests/convert/data_color_mine.rs"]
#[path = "../../palette/tests/convert/data_color_mine.rs"]
#[allow(dead_code)]
mod data_color_mine;
use data_color_mine::{load_data, ColorMine};
Expand All @@ -26,7 +26,7 @@ fn cie_conversion(c: &mut Criterion) {
0,
"number of colors must be a multiple of 8 for a fair comparison with SIMD"
);
#[cfg(feature = "wide")]

let wide_colormine: Vec<_> = colormine
.chunks_exact(8)
.map(|chunk| {
Expand Down Expand Up @@ -80,9 +80,8 @@ fn cie_conversion(c: &mut Criterion) {
}
})
});
#[cfg(feature = "wide")]
group.bench_with_input(
"linsrgb to xyz - wide::f32x8",
"linsrgb to xyz - wide f32x8",
&wide_colormine,
|b, wide_colormine| {
b.iter(|| {
Expand Down
2 changes: 1 addition & 1 deletion palette/benches/matrix.rs → benchmarks/benches/matrix.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use codspeed_criterion_compat::{black_box, criterion_group, criterion_main, Criterion};

use palette::encoding;
use palette::matrix::{
Expand Down
21 changes: 8 additions & 13 deletions palette/benches/rgb.rs → benchmarks/benches/rgb.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use codspeed_criterion_compat::{black_box, criterion_group, criterion_main, Criterion};
use palette::convert::FromColorUnclamped;
use palette::encoding;
use palette::{Hsl, Hsv, Hwb, IntoColor, LinSrgb, Srgb};
Expand All @@ -10,7 +10,7 @@ type LinHsv = Hsv<encoding::Linear<encoding::Srgb>>;
type LinHsl = Hsl<encoding::Linear<encoding::Srgb>>;
type LinHwb = Hwb<encoding::Linear<encoding::Srgb>>;

#[path = "../tests/convert/data_color_mine.rs"]
#[path = "../../palette/tests/convert/data_color_mine.rs"]
#[allow(dead_code)]
mod data_color_mine;
use data_color_mine::{load_data, ColorMine};
Expand Down Expand Up @@ -46,7 +46,7 @@ fn rgb_conversion(c: &mut Criterion) {
0,
"number of colors must be a multiple of 8 for a fair comparison with SIMD"
);
#[cfg(feature = "wide")]

let wide_colormine: Vec<_> = colormine
.chunks_exact(8)
.map(|chunk| {
Expand Down Expand Up @@ -80,9 +80,8 @@ fn rgb_conversion(c: &mut Criterion) {
}
})
});
#[cfg(feature = "wide")]
group.bench_with_input(
"rgb to linsrgb - wide::f32x8",
"rgb to linsrgb - wide f32x8",
&wide_colormine,
|b, wide_colormine| {
b.iter(|| {
Expand All @@ -99,9 +98,8 @@ fn rgb_conversion(c: &mut Criterion) {
}
})
});
#[cfg(feature = "wide")]
group.bench_with_input(
"rgb to hsl - wide::f32x8",
"rgb to hsl - wide f32x8",
&wide_colormine,
|b, wide_colormine| {
b.iter(|| {
Expand All @@ -125,9 +123,8 @@ fn rgb_conversion(c: &mut Criterion) {
}
})
});
#[cfg(feature = "wide")]
group.bench_with_input(
"rgb to hsv - wide::f32x8",
"rgb to hsv - wide f32x8",
&wide_colormine,
|b, wide_colormine| {
b.iter(|| {
Expand Down Expand Up @@ -165,9 +162,8 @@ fn rgb_conversion(c: &mut Criterion) {
}
})
});
#[cfg(feature = "wide")]
group.bench_with_input(
"xyz to linsrgb - wide::f32x8",
"xyz to linsrgb - wide f32x8",
&wide_colormine,
|b, wide_colormine| {
b.iter(|| {
Expand Down Expand Up @@ -240,9 +236,8 @@ fn rgb_conversion(c: &mut Criterion) {
}
})
});
#[cfg(feature = "wide")]
group.bench_with_input(
"linsrgb to rgb - wide::f32x8",
"linsrgb to rgb - wide f32x8",
&wide_colormine,
|b, wide_colormine| {
b.iter(|| {
Expand Down
19 changes: 0 additions & 19 deletions palette/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,6 @@ version = "3.2.25"
default-features = false
features = ["std"] # Required since 3.2.25

[dev-dependencies.criterion]
version = "0.4.0"
default-features = false

[dev-dependencies.image]
version = "0.23.14"
default-features = false
Expand All @@ -104,20 +100,5 @@ version = "4"
default-features = false
features = ["rand-traits"]

[[bench]]
path = "benches/cie.rs"
name = "cie_conversion"
harness = false

[[bench]]
path = "benches/rgb.rs"
name = "rgb_conversion"
harness = false

[[bench]]
path = "benches/matrix.rs"
name = "matrix"
harness = false

[package.metadata.docs.rs]
all-features = true

0 comments on commit 8a2fbfa

Please sign in to comment.