Skip to content

Commit

Permalink
Improved building
Browse files Browse the repository at this point in the history
  • Loading branch information
rcastill committed Jul 5, 2022
1 parent 44cbee0 commit e096da7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ RS_FILES=$(shell find . -name '*.rs' -type f)

save_as: $(RS_FILES)
cargo build --release --example save_as
[ ! -f save_as ] && ln -s target/release/examples/save_as save_as
ln -fs target/release/examples/save_as save_as

clean:
rm -f save_as
20 changes: 10 additions & 10 deletions examples/save_as.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,26 @@ fn main() -> Result<()> {
let mat = imread("examples/tinta_helada.jpg", IMREAD_COLOR)?;
let imread_elapsed = start.elapsed();

// let start = Instant::now();
// let mut mat2 = mat;
// cvt_color(&mat, &mut mat2, COLOR_BGR2RGB, 0)?;
// let mat2_elapsed = start.elapsed();
// eprintln!("mat2 = {mat2_elapsed:?}");

// Convert it to image::DynamicImage
let start = Instant::now();
#[cfg(not(feature = "rayon"))]
let im = mat.to_image()?;
#[cfg(feature = "rayon")]
let _im = mat.to_image()?;
let conv_elapsed = start.elapsed();

#[cfg(feature = "rayon")]
let conv_par_elapsed = {
let (conv_par_elapsed, im_par) = {
let start = Instant::now();
let _im_par = mat.to_image_par()?;
start.elapsed()
let im = mat.to_image_par()?;
(start.elapsed(), im)
};

// Convert it to ImageBuffer using unsafe (fast + no allocations)
#[cfg(feature = "experimental")]
let conv_noalloc_elapsed = {
let start = Instant::now();
let _im = mat.as_image_buffer()?;
let im = mat.as_image_buffer()?;
start.elapsed()
};

Expand All @@ -58,7 +55,10 @@ fn main() -> Result<()> {
})
.unwrap_or_else(|| Cow::Borrowed("out.jpg"));
let start = Instant::now();
#[cfg(not(feature = "rayon"))]
im.save(&*outfile)?;
#[cfg(feature = "rayon")]
im_par.save(&*outfile)?;
let save_elapsed = start.elapsed();

// test
Expand Down

0 comments on commit e096da7

Please sign in to comment.