Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some typos #192

Merged
merged 1 commit into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions compare/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Even the fallback algorithm is in the top 5 in terms of throughput, beating out

aHash is the fastest non-trivial hasher implementation in Rust. Below is a comparison with 10 other popular hashing algorithms.

![Hasher perfromance](https://docs.google.com/spreadsheets/d/e/2PACX-1vSK7Li2nS-Bur9arAYF9IfT37MP-ohAe1v19lZu5fd9MajI1fSveLAQZyEie4Ea9k5-SWHTff7nL2DW/pubchart?oid=1323618938&format=image)
![Hasher performance](https://docs.google.com/spreadsheets/d/e/2PACX-1vSK7Li2nS-Bur9arAYF9IfT37MP-ohAe1v19lZu5fd9MajI1fSveLAQZyEie4Ea9k5-SWHTff7nL2DW/pubchart?oid=1323618938&format=image)

## DOS resistance

Expand Down Expand Up @@ -120,4 +120,4 @@ Similarly, wyHash is targeted at hashmaps. WyHash is quite fast, but is not DOS

There are fixed strings which when encountered caused the internal state to reset. This makes wyHash trivial to attack.

AHash outperforms wyHash across all input sizes, regardless of which CPU instructions are available.
AHash outperforms wyHash across all input sizes, regardless of which CPU instructions are available.
24 changes: 12 additions & 12 deletions src/hash_quality_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,40 +108,40 @@ fn test_keys_change_output<T: Hasher>(constructor: impl Fn(u128, u128) -> T) {
fn test_input_affect_every_byte<T: Hasher>(constructor: impl Fn(u128, u128) -> T) {
let base = hash_with(&0, constructor(0, 0));
for shift in 0..16 {
let mut alternitives = vec![];
let mut alternatives = vec![];
for v in 0..256 {
let input = (v as u128) << (shift * 8);
let hasher = constructor(0, 0);
alternitives.push(hash_with(&input, hasher));
alternatives.push(hash_with(&input, hasher));
}
assert_each_byte_differs(shift, base, alternitives);
assert_each_byte_differs(shift, base, alternatives);
}
}

///Ensures that for every bit in the output there is some value for each byte in the key that flips it.
fn test_keys_affect_every_byte<H: Hash, T: Hasher>(item: H, constructor: impl Fn(u128, u128) -> T) {
let base = hash_with(&item, constructor(0, 0));
for shift in 0..16 {
let mut alternitives1 = vec![];
let mut alternitives2 = vec![];
let mut alternatives1 = vec![];
let mut alternatives2 = vec![];
for v in 0..256 {
let input = (v as u128) << (shift * 8);
let hasher1 = constructor(input, 0);
let hasher2 = constructor(0, input);
let h1 = hash_with(&item, hasher1);
let h2 = hash_with(&item, hasher2);
alternitives1.push(h1);
alternitives2.push(h2);
alternatives1.push(h1);
alternatives2.push(h2);
}
assert_each_byte_differs(shift, base, alternitives1);
assert_each_byte_differs(shift, base, alternitives2);
assert_each_byte_differs(shift, base, alternatives1);
assert_each_byte_differs(shift, base, alternatives2);
}
}

fn assert_each_byte_differs(num: u64, base: u64, alternitives: Vec<u64>) {
fn assert_each_byte_differs(num: u64, base: u64, alternatives: Vec<u64>) {
let mut changed_bits = 0_u64;
for alternitive in alternitives {
changed_bits |= base ^ alternitive
for alternative in alternatives {
changed_bits |= base ^ alternative
}
assert_eq!(
core::u64::MAX,
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ use ahash::AHashMap;
let mut map: AHashMap<i32, i32> = AHashMap::new();
map.insert(12, 34);
```
This avoids the need to type "RandomState". (For convience `From`, `Into`, and `Deref` are provided).
This avoids the need to type "RandomState". (For convenience `From`, `Into`, and `Deref` are provided).

# Aliases

Expand Down
Loading