进行一些边界优化
This commit is contained in:
parent
364364215a
commit
99a1d49539
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -1831,7 +1831,7 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tswn"
|
name = "tswn"
|
||||||
version = "0.1.1"
|
version = "0.1.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base16384",
|
"base16384",
|
||||||
"chrono",
|
"chrono",
|
||||||
|
46
bench/tswn.md
Normal file
46
bench/tswn.md
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
# tswn 效率记录
|
||||||
|
|
||||||
|
## 0.1.1
|
||||||
|
|
||||||
|
```text
|
||||||
|
2024-04-25T14:38:37.928073Z INFO tswn: 输出文件: "./namerena/namerena-shenjacks-2024-04-25_22-38-37.txt"
|
||||||
|
2024-04-25T14:38:37.928448Z INFO tswn: 开始: 0 结尾: 100000000
|
||||||
|
2024-04-25T14:38:37.928527Z INFO tswn: 线程数: 1
|
||||||
|
2024-04-25T14:38:37.928582Z INFO tswn: 八围预期: 640
|
||||||
|
2024-04-25T14:38:37.928633Z INFO tswn: 队伍名: shenjacks
|
||||||
|
2024-04-25T14:38:37.928689Z INFO tswn: 输出文件名: "./namerena/namerena-shenjacks-2024-04-25_22-38-37.txt"
|
||||||
|
2024-04-25T14:38:37.928773Z INFO tswn: 开始计算
|
||||||
|
2024-04-25T14:38:37.928857Z INFO tswn: 线程 thread_0 开始计算
|
||||||
|
2024-04-25T14:38:37.947371Z INFO tswn::cacluate: | 1|Id: 10000|542408.18/s 468.641E/d 0.02⬆️|0 |预计:0:3:4|
|
||||||
|
2024-04-25T14:38:48.111355Z INFO tswn::cacluate: | 1|Id: 5434080|533663.84/s 461.086E/d 10.16⬇️|0 |预计:0:2:57|
|
||||||
|
2024-04-25T14:38:58.566294Z INFO tswn::cacluate: | 1|Id: 10770710|510448.33/s 441.027E/d 10.45⬇️|0 |预计:0:2:54|
|
||||||
|
2024-04-25T14:39:08.419676Z INFO tswn::cacluate: | 1|Id: 15875190|518062.38/s 447.606E/d 9.85⬆️|0 |预计:0:2:42|
|
||||||
|
2024-04-25T14:39:18.371574Z INFO tswn::cacluate: | 1|Id: 21055810|520575.43/s 449.777E/d 9.95⬆️|0 |预计:0:2:31|
|
||||||
|
2024-04-25T14:39:28.277127Z INFO tswn::cacluate: | 1|Id: 26261560|525550.00/s 454.075E/d 9.91⬆️|0 |预计:0:2:20|
|
||||||
|
2024-04-25T14:39:38.073338Z INFO tswn::cacluate: | 1|Id: 31517060|536495.12/s 463.532E/d 9.80⬆️|0 |预计:0:2:7|
|
||||||
|
2024-04-25T14:39:48.224642Z INFO tswn::cacluate: | 1|Id: 36882010|528507.78/s 456.631E/d 10.15⬇️|0 |预计:0:1:59|
|
||||||
|
```
|
||||||
|
|
||||||
|
## 0.1.2
|
||||||
|
|
||||||
|
```text
|
||||||
|
2024-04-25T14:49:18.046424Z INFO tswn: 输出文件: "./namerena/namerena-shenjacks-2024-04-25_22-49-18.txt"
|
||||||
|
2024-04-25T14:49:18.046647Z INFO tswn: 开始: 0 结尾: 100000000
|
||||||
|
2024-04-25T14:49:18.046739Z INFO tswn: 线程数: 1
|
||||||
|
2024-04-25T14:49:18.046814Z INFO tswn: 八围预期: 640
|
||||||
|
2024-04-25T14:49:18.046888Z INFO tswn: 队伍名: shenjacks
|
||||||
|
2024-04-25T14:49:18.046961Z INFO tswn: 输出文件名: "./namerena/namerena-shenjacks-2024-04-25_22-49-18.txt"
|
||||||
|
2024-04-25T14:49:18.047072Z INFO tswn: 开始计算
|
||||||
|
2024-04-25T14:49:18.047205Z INFO tswn: 线程 thread_0 开始计算
|
||||||
|
2024-04-25T14:49:18.067274Z INFO tswn::cacluate: | 1|Id: 10000|500668.39/s 432.577E/d 0.02⬆️|0 |预计:0:3:19|
|
||||||
|
2024-04-25T14:49:26.959820Z INFO tswn::cacluate: | 1|Id: 5016680|563031.98/s 486.460E/d 8.89⬆️|0 |预计:0:2:48|
|
||||||
|
2024-04-25T14:49:37.050652Z INFO tswn::cacluate: | 1|Id: 10646990|557974.03/s 482.090E/d 10.09⬇️|0 |预计:0:2:40|
|
||||||
|
2024-04-25T14:49:47.117235Z INFO tswn::cacluate: | 1|Id: 16226730|554294.40/s 478.910E/d 10.07⬇️|0 |预计:0:2:31|
|
||||||
|
2024-04-25T14:49:57.134571Z INFO tswn::cacluate: | 1|Id: 21769670|553354.55/s 478.098E/d 10.02⬇️|0 |预计:0:2:21|
|
||||||
|
2024-04-25T14:50:07.084869Z INFO tswn::cacluate: | 1|Id: 27303210|556126.12/s 480.493E/d 9.95⬆️|0 |预计:0:2:10|
|
||||||
|
2024-04-25T14:50:17.165308Z INFO tswn::cacluate: | 1|Id: 32864470|551717.27/s 476.684E/d 10.08⬇️|0 |预计:0:2:1|
|
||||||
|
2024-04-25T14:50:27.177012Z INFO tswn::cacluate: | 1|Id: 38381640|551097.33/s 476.148E/d 10.01⬇️|0 |预计:0:1:51|
|
||||||
|
2024-04-25T14:50:37.102177Z INFO tswn::cacluate: | 1|Id: 43892610|555281.37/s 479.763E/d 9.92⬆️|0 |预计:0:1:41|
|
||||||
|
2024-04-25T14:50:47.147717Z INFO tswn::cacluate: | 1|Id: 49445420|552772.98/s 477.596E/d 10.05⬇️|0 |预计:0:1:31|
|
||||||
|
2024-04-25T14:50:57.108934Z INFO tswn::cacluate: | 1|Id: 54973140|554932.97/s 479.462E/d 9.96⬆️|0 |预计:0:1:21|
|
||||||
|
```
|
@ -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.1"
|
version = "0.1.2"
|
||||||
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
|
||||||
|
@ -141,7 +141,12 @@ impl Namer {
|
|||||||
unsafe { val.swap_unchecked(s as usize, 0) };
|
unsafe { val.swap_unchecked(s as usize, 0) };
|
||||||
let mut k = 0;
|
let mut k = 0;
|
||||||
for i in 0..256 {
|
for i in 0..256 {
|
||||||
s = s.wrapping_add(if k == 0 { 0 } else { name_bytes[k - 1] });
|
// s = s.wrapping_add(if k == 0 { 0 } else { name_bytes[k - 1] });
|
||||||
|
s = s.wrapping_add(if k == 0 {
|
||||||
|
0
|
||||||
|
} else {
|
||||||
|
*unsafe { name_bytes.get_unchecked(k - 1) }
|
||||||
|
});
|
||||||
s = s.wrapping_add(val[i]);
|
s = s.wrapping_add(val[i]);
|
||||||
unsafe { val.swap_unchecked(i, s as usize) }
|
unsafe { val.swap_unchecked(i, s as usize) }
|
||||||
k = if k == b_name_len - 1 { 0 } else { k + 1 };
|
k = if k == b_name_len - 1 { 0 } else { k + 1 };
|
||||||
@ -158,25 +163,39 @@ impl Namer {
|
|||||||
|
|
||||||
for i in (0..256).step_by(64) {
|
for i in (0..256).step_by(64) {
|
||||||
// 一次性加载64个数字
|
// 一次性加载64个数字
|
||||||
let mut x = u8x64::from_slice(&simd_val[i..]);
|
// let mut x = u8x64::from_slice(&simd_val[i..]);
|
||||||
|
let mut x = u8x64::from_slice(unsafe { simd_val.get_unchecked(i..) });
|
||||||
x = x * simd_181 + simd_160;
|
x = x * simd_181 + simd_160;
|
||||||
// 写入到 simd_val
|
// 写入到 simd_val
|
||||||
x.copy_to_slice(&mut simd_val[i..]);
|
// x.copy_to_slice(&mut simd_val[i..]);
|
||||||
|
unsafe {
|
||||||
|
x.copy_to_slice(simd_val.get_unchecked_mut(i..));
|
||||||
|
}
|
||||||
|
|
||||||
let y = x & simd_63;
|
let y = x & simd_63;
|
||||||
y.copy_to_slice(&mut simd_val_b[i..]);
|
// y.copy_to_slice(&mut simd_val_b[i..]);
|
||||||
|
unsafe {
|
||||||
|
y.copy_to_slice(simd_val_b.get_unchecked_mut(i..));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut mod_count = 0;
|
let mut mod_count = 0;
|
||||||
|
|
||||||
for i in 0..96 {
|
for i in 0..96 {
|
||||||
if simd_val[i] > 88 && simd_val[i] < 217 {
|
// if simd_val[i] > 88 && simd_val[i] < 217 {
|
||||||
// name_base[mod_count as usize] = simd_val_b[i];
|
// // name_base[mod_count as usize] = simd_val_b[i];
|
||||||
unsafe {
|
// unsafe {
|
||||||
|
// *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) > &88 && simd_val.get_unchecked(i) < &217 {
|
||||||
*name_base.get_unchecked_mut(mod_count as usize) =
|
*name_base.get_unchecked_mut(mod_count as usize) =
|
||||||
*simd_val_b.get_unchecked(i);
|
*simd_val_b.get_unchecked(i);
|
||||||
|
mod_count += 1;
|
||||||
}
|
}
|
||||||
mod_count += 1;
|
|
||||||
}
|
}
|
||||||
if mod_count > 30 {
|
if mod_count > 30 {
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user