Skip to content

Commit

Permalink
Address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomsonTan committed Jun 10, 2024
1 parent 18438d6 commit f24ba61
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions stress/src/throughput.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,23 @@ where
})
.expect("Error setting Ctrl-C handler");

let args: Vec<String> = env::args().collect();

let mut num_threads = num_cpus::get();
if args.len() >= 2 {
let arg = args[1].parse::<usize>();
let mut args_iter = env::args();

if let Some(arg_str) = args_iter.nth(1) {
let arg = arg_str.parse::<usize>();

if !arg.is_ok() {
eprintln!("Invalid command line argument '{}' as number of threads. Make sure the value is a positive integer.", args[1]);
eprintln!("Invalid command line argument '{}' as number of threads. Make sure the value is a positive integer.", arg_str);
std::process::exit(1);
}

let arg_num = arg.unwrap();

if arg_num > 0 && arg_num <= num_threads as i32 {
if arg_num > 0 && arg_num <= num_threads {
num_threads = arg_num as usize;
} else {
eprintln!("Invalid command line argument {} as number of threads. Make sure the value is above 0 and less than or equal to {}.", arg_num, num_threads);
eprintln!("Invalid command line argument {} as number of threads. Make sure the value is above 0 and less than or equal to number of available logical cores ({}).", arg_num, num_threads);
std::process::exit(1);
}
}
Expand Down

0 comments on commit f24ba61

Please sign in to comment.