make image preloading parallel

This commit is contained in:
fkarg
2020-02-05 00:05:19 +01:00
parent 9343e7a7f7
commit 66ae16f13d
4 changed files with 5 additions and 1 deletions

1
Cargo.lock generated
View File

@@ -279,6 +279,7 @@ dependencies = [
"clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)",
"image 0.22.3 (registry+https://github.com/rust-lang/crates.io-index)",
"num_cpus 1.11.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rayon 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
]

View File

@@ -9,6 +9,7 @@ clap = "2.31"
image = "0.22"
num_cpus = "1.8"
regex = "1.3"
rayon = "1.3.0"
[profile.release]
lto = true

View File

@@ -1,6 +1,7 @@
use std::path::Path;
use std::thread::sleep;
use std::time::Duration;
use rayon::prelude::*;
use image;
use image::{DynamicImage, FilterType};
@@ -32,7 +33,7 @@ impl ImageManager {
// Load the images from the paths
let image_manager =
ImageManager::from(paths.iter().map(|path| load_image(path, size)).collect());
ImageManager::from(paths.par_iter().map(|path| load_image(path, size)).collect());
// TODO: process the image slices

View File

@@ -1,5 +1,6 @@
extern crate clap;
extern crate image;
extern crate rayon;
mod app;
mod arg_handler;