Skip to content

Commit

Permalink
add trait IntoColor benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
sidred committed Feb 20, 2016
1 parent 7f45aea commit ab2ffa9
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
20 changes: 19 additions & 1 deletion benches/rgb_to_hsl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ extern crate palette;

use test::Bencher;
use num::{Float, ToPrimitive, NumCast, One, Zero};
use palette::{Rgb, Hsl};
use palette::{Rgb, Hsl, IntoColor};

#[bench]
fn rgb_to_hsl_original_f64(b: &mut Bencher) {
Expand All @@ -20,6 +20,15 @@ fn rgb_to_hsl_original_f64(b: &mut Bencher) {
})
}
#[bench]
fn rgb_to_hsl_trait_f64(b: &mut Bencher) {
let input = Rgb::new(0.7_f64, 0.8 , 0.64);
b.iter(|| {
let x = test::black_box(input);
let y = x.into_hsl();
test::black_box(y)
})
}
#[bench]
fn rgb_to_hsl_optimized_f64(b: &mut Bencher) {
let input = Rgb::new(0.7_f64, 0.8 , 0.64);
b.iter(|| {
Expand All @@ -38,6 +47,15 @@ fn rgb_to_hsl_original_f32(b: &mut Bencher) {
})
}
#[bench]
fn rgb_to_hsl_trait_f32(b: &mut Bencher) {
let input = Rgb::new(0.7_f32, 0.8 , 0.64);
b.iter(|| {
let x = test::black_box(input);
let y = x.into_hsl();
test::black_box(y)
})
}
#[bench]
fn rgb_to_hsl_optimized_f32(b: &mut Bencher) {
let input = Rgb::new(0.7_f32, 0.8 , 0.64);
b.iter(|| {
Expand Down
20 changes: 19 additions & 1 deletion benches/rgb_to_hsv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ extern crate palette;

use test::Bencher;
use num::{Float, ToPrimitive, NumCast, Zero};
use palette::{Rgb, Hsv};
use palette::{Rgb, Hsv, IntoColor};

#[bench]
fn rgb_to_hsv_original_f64(b: &mut Bencher) {
Expand All @@ -20,6 +20,15 @@ fn rgb_to_hsv_original_f64(b: &mut Bencher) {
})
}
#[bench]
fn rgb_to_hsv_trait_f64(b: &mut Bencher) {
let input = Rgb::new(0.7_f64, 0.8 , 0.64);
b.iter(|| {
let x = test::black_box(input);
let y = x.into_hsv();
test::black_box(y)
})
}
#[bench]
fn rgb_to_hsv_optimized_f64(b: &mut Bencher) {
let input = Rgb::new(0.7_f64, 0.8 , 0.64);
b.iter(|| {
Expand All @@ -38,6 +47,15 @@ fn rgb_to_hsv_original_f32(b: &mut Bencher) {
})
}
#[bench]
fn rgb_to_hsv_trait_f32(b: &mut Bencher) {
let input = Rgb::new(0.7_f32, 0.8 , 0.64);
b.iter(|| {
let x = test::black_box(input);
let y = x.into_hsv();
test::black_box(y)
})
}
#[bench]
fn rgb_to_hsv_optimized_f32(b: &mut Bencher) {
let input = Rgb::new(0.7_f32, 0.8 , 0.64);
b.iter(|| {
Expand Down

0 comments on commit ab2ffa9

Please sign in to comment.