Compare commits

...

2 Commits

2 changed files with 14 additions and 8 deletions

View File

@ -36,10 +36,10 @@ were performed on Framework Laptop (A6) with an 11th Gen Intel® Core™ i7-1165
for 30 seconds using one thread.
```
counter: 163,504,123 hashes (5,461,682.8102/s)
header: 124,617,875 hashes (4,150,993.2260/s)
random: 110,886,440 hashes (3,715,452.2177/s)
increment: 107,137,532 hashes (3,573,438.8338/s)
counter: 162,092,475 hashes (5,397,324.7345/s)
header: 139,819,851 hashes (4,632,819.3559/s)
random: 125,880,577 hashes (4,205,520.4347/s)
increment: 101,819,680 hashes (3,361,825.5571/s)
sequoia*: 864,486 hashes ( 28,923.1870/s)
sequoia: 339,407 hashes ( 11,403.6102/s)
gpg-agent: 353 hashes ( 11.7519/s)

View File

@ -494,6 +494,8 @@ fn main() -> Result<()> {
let mut sha1 = Sha1::default();
let mut buffer = itoa::Buffer::new();
let mut count_buffer = itoa::Buffer::new();
let mut random_bytes = [0; 16];
let mut random_hex = [0; 32];
let mut first = true;
while !found.load(Ordering::SeqCst) {
let append = if gpg.is_some() || seq_key.is_some() {
@ -501,9 +503,13 @@ fn main() -> Result<()> {
} else {
match method {
Method::Random => {
let mut bytes = [0; 16];
rand::thread_rng().fill(&mut bytes);
Some(Cow::from(data_encoding::HEXLOWER.encode(&bytes)))
rand::thread_rng().fill(&mut random_bytes);
data_encoding::HEXLOWER.encode_mut(&random_bytes, &mut random_hex);
let random = unsafe {
std::str::from_utf8_unchecked(&random_hex)
};
Some(Cow::from(random))
}
Method::Counter => {
let count = counter.fetch_add(1, Ordering::SeqCst) + 1;
@ -517,7 +523,7 @@ fn main() -> Result<()> {
let timestamp = match method {
Method::Decrement => timestamp.fetch_sub(1, Ordering::SeqCst) - 1,
Method::Increment => timestamp.fetch_add(1, Ordering::SeqCst) + 1,
_ => timestamp.load(Ordering::SeqCst),
_ => unreachable!(),
};
author_parts[author_len - 2] = buffer.format(timestamp).to_owned();