diff options
author | Lars Wirzenius <liw@sequoia-pgp.org> | 2022-05-18 19:10:12 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@sequoia-pgp.org> | 2022-05-18 19:10:12 +0300 |
commit | 734c2e2fa820fccf60ae7633f0bb073bd2301a01 (patch) | |
tree | 4472a0434cbb84d8564d5bb069ef4703c9671516 | |
parent | 21978c9fb6440714e6b80d18a38c894d88e37dff (diff) | |
download | checksums-734c2e2fa820fccf60ae7633f0bb073bd2301a01.tar.gz |
Sponsored-by: author
-rw-r--r-- | src/main.rs | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/src/main.rs b/src/main.rs index d21e67a..9599522 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,42 +3,39 @@ use clap::Parser; use std::time::Instant; fn main() { + if let Err(err) = run() { + eprintln!("ERROR: {}", err); + std::process::exit(1); + } +} + +fn run() -> Result<(), std::io::Error> { let args = Args::parse(); println!("linear"); let started = Instant::now(); - if let Err(e) = linear::checksums(&args.filenames) { - eprintln!("ERROR: {e}"); - std::process::exit(1); - } + linear::checksums(&args.filenames)?; println!("{} ms", started.elapsed().as_millis()); println!(); println!("linear iterator"); let started = Instant::now(); - if let Err(e) = lineariter::checksums(&args.filenames) { - eprintln!("ERROR: {e}"); - std::process::exit(1); - } + lineariter::checksums(&args.filenames)?; println!("{} ms", started.elapsed().as_millis()); println!(); println!("rayon"); let started = Instant::now(); - if let Err(e) = rayon::checksums(&args.filenames) { - eprintln!("ERROR: {e}"); - std::process::exit(1); - } + rayon::checksums(&args.filenames)?; println!("{} ms", started.elapsed().as_millis()); println!(); println!("threads"); let started = Instant::now(); - if let Err(e) = threads::checksums(&args.filenames) { - eprintln!("ERROR: {e}"); - std::process::exit(1); - } + threads::checksums(&args.filenames)?; println!("{} ms", started.elapsed().as_millis()); + + Ok(()) } mod linear { |