Vendor rawler 0.7.2 unmodified
The crate as crates.io publishes it, minus .cargo-ok, its Cargo.lock and data/testdata (13 MB of sample files only its own tests read). Not yet routed through [patch.crates-io]; the next commit is the patch.
This commit is contained in:
+51
@@ -0,0 +1,51 @@
|
||||
use std::env;
|
||||
use std::path::PathBuf;
|
||||
use std::time::Instant;
|
||||
|
||||
use rawler::decoders::RawDecodeParams;
|
||||
use rawler::rawsource::RawSource;
|
||||
|
||||
fn usage() {
|
||||
println!("benchmark <file>");
|
||||
std::process::exit(1);
|
||||
}
|
||||
|
||||
static ITERATIONS: u64 = 50;
|
||||
|
||||
fn error(err: &str) {
|
||||
println!("ERROR: {}", err);
|
||||
std::process::exit(2);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let args: Vec<_> = env::args().collect();
|
||||
if args.len() != 2 {
|
||||
usage();
|
||||
}
|
||||
let file = &args[1];
|
||||
println!("Loading file \"{}\"", file);
|
||||
|
||||
let rawfile = RawSource::new(&PathBuf::from(file)).expect("failed to load raw file");
|
||||
let rawloader = rawler::RawLoader::new();
|
||||
|
||||
let from_time = Instant::now();
|
||||
{
|
||||
for _ in 0..ITERATIONS {
|
||||
let decoder = match rawloader.get_decoder(&rawfile) {
|
||||
Ok(val) => val,
|
||||
Err(e) => {
|
||||
error(&e.to_string());
|
||||
return;
|
||||
}
|
||||
};
|
||||
match decoder.raw_image(&rawfile, &RawDecodeParams::default(), false) {
|
||||
Ok(_) => {}
|
||||
Err(e) => error(&e.to_string()),
|
||||
}
|
||||
}
|
||||
}
|
||||
let duration = from_time.elapsed();
|
||||
|
||||
let avgtime = ((duration.as_nanos() as u64) / ITERATIONS / 1000) as f64 / 1000.0;
|
||||
println!("Average decode time: {} ms ({} iterations)", avgtime, ITERATIONS);
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
use std::env;
|
||||
|
||||
fn main() {
|
||||
let args: Vec<_> = env::args().collect();
|
||||
if args.len() != 2 {
|
||||
println!("Usage: {} <file>", args[0]);
|
||||
std::process::exit(2);
|
||||
}
|
||||
let file = &args[1];
|
||||
match rawler::decode_file(file) {
|
||||
Ok(_) => println!("OK file"),
|
||||
Err(_) => println!("FAILED file"),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user