Fix calculation start point in cacl function
This commit is contained in:
parent
9269acf241
commit
46e1bf18a8
@ -54,11 +54,11 @@ pub struct Command {
|
||||
pub team: String,
|
||||
}
|
||||
|
||||
fn cacl(max: u64, step: usize, top: u32, id: u64, team: &String) {
|
||||
fn cacl(start: u64, max: u64, step: usize, top: u32, id: u64, team: &String) {
|
||||
let mut start_time = std::time::Instant::now();
|
||||
let mut k: u64 = 0;
|
||||
let mut top = top;
|
||||
for i in (0+id..max).step_by(step) {
|
||||
for i in (start+id..max).step_by(step) {
|
||||
let name = gen_name(i as u64);
|
||||
// let full_name = format!("{}@shenjack", name);
|
||||
// let namer = name::Namer::new(&full_name);
|
||||
@ -99,13 +99,14 @@ fn main() {
|
||||
for i in 0..cli_arg.thread_count {
|
||||
let top = cli_arg.top;
|
||||
let max = cli_arg.end;
|
||||
let start = cli_arg.start;
|
||||
n += 1;
|
||||
let thread_name = format!("thread_{}", i);
|
||||
let thread_count = cli_arg.thread_count;
|
||||
let team = cli_arg.team.clone();
|
||||
threads.push(std::thread::spawn(move || {
|
||||
info!("线程 {} 开始计算", thread_name);
|
||||
cacl(max as u64, thread_count as usize, top as u32, n as u64, &team);
|
||||
cacl(start, max as u64, thread_count as usize, top as u32, n as u64, &team);
|
||||
info!("线程 {} 结束计算", thread_name);
|
||||
}));
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
use tracing::warn;
|
||||
|
||||
#[inline(always)]
|
||||
pub fn median<T>(x: T, y: T, z: T) -> T
|
||||
where
|
||||
T: std::cmp::Ord + std::marker::Copy,
|
||||
@ -112,7 +113,13 @@ impl Namer {
|
||||
let mut r = name_base[0..32].to_vec();
|
||||
for i in (10..31).step_by(3) {
|
||||
r[i..i + 3].sort_unstable();
|
||||
name_prop[prop_cnt] = median(r[i], r[i + 1], r[i + 2]) as u32;
|
||||
let med = median(r[i], r[i + 1], r[i + 2]);
|
||||
// let max_ = r[i].max(r[i + 1]).max(r[i + 2]);
|
||||
// let min_ = r[i].min(r[i + 1]).min(r[i + 2]);
|
||||
// r[i] = min_;
|
||||
// r[i + 1] = med;
|
||||
// r[i + 2] = max_;
|
||||
name_prop[prop_cnt] = med as u32;
|
||||
prop_cnt += 1;
|
||||
}
|
||||
r[0..10].sort_unstable();
|
||||
|
Loading…
Reference in New Issue
Block a user