榨干!

This commit is contained in:
shenjack 2024-04-26 01:00:01 +08:00
parent 10fa61ff55
commit 0b181fab6e
Signed by: shenjack
GPG Key ID: 7B1134A979775551
4 changed files with 50 additions and 31 deletions

2
Cargo.lock generated
View File

@ -1831,7 +1831,7 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b"
[[package]] [[package]]
name = "tswn" name = "tswn"
version = "0.1.4" version = "0.1.5"
dependencies = [ dependencies = [
"base16384", "base16384",
"chrono", "chrono",

View File

@ -1,7 +1,7 @@
[package] [package]
name = "tswn" name = "tswn"
description = "tool shenjack work shop namerena" description = "tool shenjack work shop namerena"
version = "0.1.4" version = "0.1.5"
edition = "2021" edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@ -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 ### 0.1.4
> 说啥来啥 > 说啥来啥

View File

@ -255,10 +255,9 @@ impl Namer {
pub fn update_skill(&mut self) { pub fn update_skill(&mut self) {
let skill_id = self.skl_id.as_mut(); let skill_id = self.skl_id.as_mut();
for i in 0..40 { for i in 0..40 {
skill_id[i] = i as u8; unsafe {
// unsafe { *skill_id.get_unchecked_mut(i) = i as u8;
// *skill_id.get_unchecked_mut(i) = i as u8; }
// }
} }
#[cfg(feature = "simd")] #[cfg(feature = "simd")]
@ -273,8 +272,6 @@ impl Namer {
let simd_32 = u8x64::splat(32); let simd_32 = u8x64::splat(32);
for i in (0..256).step_by(64) { 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 { unsafe {
let mut x = u8x64::from_slice(simd_val.get_unchecked(i..)); let mut x = u8x64::from_slice(simd_val.get_unchecked(i..));
let mut y = u8x64::from_slice(simd_val_b.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..)); x.copy_to_slice(simd_val.get_unchecked_mut(i..));
y.copy_to_slice(simd_val_b.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; let mut mod_count = 0;
for i in 0..256 { for i in 0..256 {
if simd_val[i] != 0 { unsafe {
self.name_base[mod_count as usize] = simd_val_b[i]; 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; 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; // const int N = 256, M = 128, K = 64, skill_cnt = 40, max_len = 25;
let mut a: u8 = 0; let mut a: u8 = 0;
@ -308,29 +299,21 @@ impl Namer {
for i in 0..40 { for i in 0..40 {
let rnd = unsafe { let rnd = unsafe {
a += 1; a += 1;
// b = b.wrapping_add(self.val[a as usize]);
b = b.wrapping_add(*self.val.get_unchecked(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); 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( 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) ((*self.val.get_unchecked(a as usize) as u16 + *self.val.get_unchecked(b as usize) as u16) & 255)
as usize, as usize,
); );
a += 1; a += 1;
// b = b.wrapping_add(self.val[a as usize]);
b = b.wrapping_add(*self.val.get_unchecked(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); 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( 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) ((*self.val.get_unchecked(a as usize) as u16 + *self.val.get_unchecked(b as usize) as u16) & 255)
as usize, as usize,
); );
(((u as u32) << 8 | t as u32) % 40) as u8 (((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 { unsafe {
s = (s as u16 + rnd as u16 + *skill_id.get_unchecked(i as usize) as u16) as u8 % 40; 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); skill_id.swap_unchecked(i as usize, s as usize);
@ -340,10 +323,12 @@ impl Namer {
let mut last = -1; let mut last = -1;
let mut j = 0; let mut j = 0;
for i in (64..128).step_by(4) { for i in (64..128).step_by(4) {
let p = min( let p = unsafe {
min(self.name_base[i + 0], self.name_base[i + 1]), min(
min(self.name_base[i + 2], self.name_base[i + 3]), 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 { if p > 10 && skill_id[j] < 35 {
self.skl_freq[j] = p - 10; self.skl_freq[j] = p - 10;
if skill_id[j] < 25 { if skill_id[j] < 25 {