Refactor end calculation in main function

This commit is contained in:
shenjack 2024-02-29 01:07:57 +08:00
parent 72f1409e1b
commit 9269acf241
Signed by: shenjack
GPG Key ID: 7B1134A979775551

View File

@ -91,14 +91,14 @@ fn main() {
// 将数据量处理成可被 thread_count 整除 // 将数据量处理成可被 thread_count 整除
let left = cli_arg.start % cli_arg.thread_count as u64; let left = cli_arg.start % cli_arg.thread_count as u64;
cli_arg.end += left; cli_arg.end = cli_arg.end.wrapping_add(left);
let mut n = 0; let mut n = 0;
let mut threads = Vec::with_capacity(cli_arg.thread_count as usize); let mut threads = Vec::with_capacity(cli_arg.thread_count as usize);
for i in 0..cli_arg.thread_count { for i in 0..cli_arg.thread_count {
let top = cli_arg.top; let top = cli_arg.top;
let max = cli_arg.end / cli_arg.thread_count as u64; let max = cli_arg.end;
n += 1; n += 1;
let thread_name = format!("thread_{}", i); let thread_name = format!("thread_{}", i);
let thread_count = cli_arg.thread_count; let thread_count = cli_arg.thread_count;