From 0b181fab6e66f6c2a85eecb3dd8d6b94c8053058 Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Fri, 26 Apr 2024 01:00:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A6=A8=E5=B9=B2=EF=BC=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.lock | 2 +- miner/Cargo.toml | 2 +- miner/docs/bench.md | 34 ++++++++++++++++++++++++++++++++++ miner/src/name.rs | 43 ++++++++++++++----------------------------- 4 files changed, 50 insertions(+), 31 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fafaf34..e394e71 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1831,7 +1831,7 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "tswn" -version = "0.1.4" +version = "0.1.5" dependencies = [ "base16384", "chrono", diff --git a/miner/Cargo.toml b/miner/Cargo.toml index 783c614..0d15c15 100644 --- a/miner/Cargo.toml +++ b/miner/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "tswn" description = "tool shenjack work shop namerena" -version = "0.1.4" +version = "0.1.5" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/miner/docs/bench.md b/miner/docs/bench.md index 2d23c7d..c9a0125 100644 --- a/miner/docs/bench.md +++ b/miner/docs/bench.md @@ -12,6 +12,40 @@ ## 结果 +### 0.1.5 + +> 要命 +> +> 不过至少榨干了 +> +> 虚评还没榨干呢就是了 + +```text +❯ .\runs\tswn-015.exe --team shenjacks -q 5500 --end 100000000 --bench +2024-04-25T16:57:24.563330Z INFO tswn: 输出文件: "./namerena/namerena-shenjacks-2024-04-26_00-57-24.txt" +2024-04-25T16:57:24.563545Z INFO tswn: 设置线程亲和性成功 4095 +2024-04-25T16:57:24.563599Z INFO tswn: 开始: 0 结尾: 100000000 +2024-04-25T16:57:24.563647Z INFO tswn: 线程数: 1 +2024-04-25T16:57:24.563699Z INFO tswn: 八围预期: 640 +2024-04-25T16:57:24.563743Z INFO tswn: 队伍名: shenjacks +2024-04-25T16:57:24.563785Z INFO tswn: 输出文件名: "./namerena/namerena-shenjacks-2024-04-26_00-57-24.txt" +2024-04-25T16:57:24.563829Z INFO tswn: 预期状态输出时间间隔: 10 秒 +2024-04-25T16:57:24.563879Z INFO tswn: 是否启动 benchmark 模式: true +2024-04-25T16:57:24.563922Z INFO tswn: 开始 benchmark +2024-04-25T16:57:24.578851Z INFO tswn::cacluate: | 1|Id: 10000|671821.78/s 580.454E/d 0.01⬆️|0 |预计:0:2:28| +2024-04-25T16:57:34.578359Z INFO tswn::cacluate: | 1|Id: 6728210|671860.35/s 580.487E/d 10.00⬆️|0 |预计:0:2:18| +2024-04-25T16:57:44.575895Z INFO tswn::cacluate: | 1|Id: 13446810|672032.96/s 580.636E/d 10.00⬆️|0 |预计:0:2:8| +2024-04-25T16:57:54.591460Z INFO tswn::cacluate: | 1|Id: 20167130|670995.58/s 579.740E/d 10.02⬇️|0 |预计:0:1:58| +2024-04-25T16:58:04.566468Z INFO tswn::cacluate: | 1|Id: 26877080|672683.34/s 581.198E/d 9.97⬆️|0 |预计:0:1:48| +2024-04-25T16:58:14.569120Z INFO tswn::cacluate: | 1|Id: 33603910|672512.54/s 581.051E/d 10.00⬇️|0 |预计:0:1:38| +2024-04-25T16:58:24.568515Z INFO tswn::cacluate: | 1|Id: 40329030|672560.85/s 581.093E/d 10.00⬆️|0 |预计:0:1:28| +2024-04-25T16:58:34.568901Z INFO tswn::cacluate: | 1|Id: 47054630|672541.67/s 581.076E/d 10.00⬇️|0 |预计:0:1:18| +2024-04-25T16:58:44.567734Z INFO tswn::cacluate: | 1|Id: 53780040|672627.21/s 581.150E/d 10.00⬆️|0 |预计:0:1:8| +2024-04-25T16:58:54.566817Z INFO tswn::cacluate: | 1|Id: 60506310|672696.30/s 581.210E/d 10.00⬆️|0 |预计:0:0:58| +2024-04-25T16:59:04.552976Z INFO tswn::cacluate: | 1|Id: 67233270|673636.33/s 582.022E/d 9.99⬆️|0 |预计:0:0:48| +2024-04-25T16:59:14.573063Z INFO tswn::cacluate: | 1|Id: 73969630|672293.31/s 580.861E/d 10.02⬇️|0 |预计:0:0:38| +``` + ### 0.1.4 > 说啥来啥 diff --git a/miner/src/name.rs b/miner/src/name.rs index 90fb3de..212c088 100644 --- a/miner/src/name.rs +++ b/miner/src/name.rs @@ -255,10 +255,9 @@ impl Namer { pub fn update_skill(&mut self) { let skill_id = self.skl_id.as_mut(); for i in 0..40 { - skill_id[i] = i as u8; - // unsafe { - // *skill_id.get_unchecked_mut(i) = i as u8; - // } + unsafe { + *skill_id.get_unchecked_mut(i) = i as u8; + } } #[cfg(feature = "simd")] @@ -273,8 +272,6 @@ impl Namer { let simd_32 = u8x64::splat(32); for i in (0..256).step_by(64) { - // let mut x = u8x64::from_slice(&simd_val[i..]); - // let mut y = u8x64::from_slice(&simd_val_b[i..]); unsafe { let mut x = u8x64::from_slice(simd_val.get_unchecked(i..)); let mut y = u8x64::from_slice(simd_val_b.get_unchecked(i..)); @@ -283,22 +280,16 @@ impl Namer { x.copy_to_slice(simd_val.get_unchecked_mut(i..)); y.copy_to_slice(simd_val_b.get_unchecked_mut(i..)); } - // x.copy_to_slice(&mut simd_val[i..]); - // y.copy_to_slice(&mut simd_val_b[i..]); } let mut mod_count = 0; for i in 0..256 { - if simd_val[i] != 0 { - self.name_base[mod_count as usize] = simd_val_b[i]; - mod_count += 1; + unsafe { + if simd_val.get_unchecked(i) != &0 { + *self.name_base.get_unchecked_mut(mod_count as usize) = *simd_val_b.get_unchecked(i); + mod_count += 1; + } } - // unsafe { - // if simd_val.get_unchecked(i) != &0 { - // *self.name_base.get_unchecked_mut(mod_count as usize) = *simd_val_b.get_unchecked(i); - // mod_count += 1; - // } - // } } // const int N = 256, M = 128, K = 64, skill_cnt = 40, max_len = 25; let mut a: u8 = 0; @@ -308,29 +299,21 @@ impl Namer { for i in 0..40 { let rnd = unsafe { a += 1; - // b = b.wrapping_add(self.val[a as usize]); b = b.wrapping_add(*self.val.get_unchecked(a as usize)); - // self.val.swap(a as usize, b as usize); self.val.swap_unchecked(a as usize, b as usize); - // let u: u8 = self.val[((self.val[a as usize] as u16 + self.val[b as usize] as u16) & 255) as usize]; let u: u8 = *self.val.get_unchecked( ((*self.val.get_unchecked(a as usize) as u16 + *self.val.get_unchecked(b as usize) as u16) & 255) as usize, ); a += 1; - // b = b.wrapping_add(self.val[a as usize]); b = b.wrapping_add(*self.val.get_unchecked(a as usize)); - // self.val.swap(a as usize, b as usize); self.val.swap_unchecked(a as usize, b as usize); - // let t = self.val[((self.val[a as usize] as u16 + self.val[b as usize] as u16) & 255) as usize]; let t: u8 = *self.val.get_unchecked( ((*self.val.get_unchecked(a as usize) as u16 + *self.val.get_unchecked(b as usize) as u16) & 255) as usize, ); (((u as u32) << 8 | t as u32) % 40) as u8 }; - // s = (s as u16 + rnd as u16 + skill_id[i] as u16) as u8 % 40; - // skill_id.swap(i as usize, s as usize); unsafe { s = (s as u16 + rnd as u16 + *skill_id.get_unchecked(i as usize) as u16) as u8 % 40; skill_id.swap_unchecked(i as usize, s as usize); @@ -340,10 +323,12 @@ impl Namer { let mut last = -1; let mut j = 0; for i in (64..128).step_by(4) { - let p = min( - min(self.name_base[i + 0], self.name_base[i + 1]), - min(self.name_base[i + 2], self.name_base[i + 3]), - ); + let p = unsafe { + min( + min(*self.name_base.get_unchecked(i + 0), *self.name_base.get_unchecked(i + 1)), + min(*self.name_base.get_unchecked(i + 2), *self.name_base.get_unchecked(i + 3)), + ) + }; if p > 10 && skill_id[j] < 35 { self.skl_freq[j] = p - 10; if skill_id[j] < 25 {