-
Notifications
You must be signed in to change notification settings - Fork 820
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Decision to give priority to long slices over short ones. Given how t…
…he size of slices can vary it is better to lose a bit (10%) on smaller slices (less than 20 bytes) and to win big on the bigger ones. Before 16 bytes the gain is -10% After 24 bytes the gain is 10% After 64 bytes the gain is 2x After 128 bytes the gain is 4x. We should control the distribution of typical workloads over time.
- Loading branch information
1 parent
1e89835
commit cca7676
Showing
6 changed files
with
385 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Voron.Util; | ||
using Xunit; | ||
|
||
namespace Voron.Tests.Util | ||
{ | ||
public class HashingTests | ||
{ | ||
|
||
[Fact] | ||
public void XXHash32() | ||
{ | ||
string value = "abcd"; | ||
uint result = Hashing.XXHash32.Calculate(Encoding.UTF8.GetBytes(value), seed: 0); | ||
uint expected = 0xA3643705; | ||
Assert.Equal(expected, result); | ||
|
||
value = "abc"; | ||
result = Hashing.XXHash32.Calculate(Encoding.UTF8.GetBytes(value), seed: 0); | ||
expected = 0x32D153FF; | ||
Assert.Equal(expected, result); | ||
|
||
value = "heiå"; | ||
result = Hashing.XXHash32.Calculate(Encoding.UTF8.GetBytes(value), seed: 0); | ||
expected = 0xDB5ABCCC; | ||
Assert.Equal(expected, result); | ||
|
||
value = "κόσμε"; | ||
result = Hashing.XXHash32.Calculate(Encoding.UTF8.GetBytes(value), seed: 0); | ||
expected = 0xD855F606; | ||
Assert.Equal(expected, result); | ||
|
||
value = "asdfasdfasdfasdfasdfasdfasdfuqrewpuqpuqruepoiqiwoerpuqowieruqwlekjrqwernq/wemnrq.,wemrn"; | ||
var bytes = Encoding.UTF8.GetBytes(value); | ||
result = Hashing.XXHash32.Calculate(bytes); | ||
expected = 3571373779; | ||
Assert.Equal(expected, result); | ||
} | ||
|
||
|
||
[Fact] | ||
public void NotEquivalenceOfBytesWithString() | ||
{ | ||
string value = "abcd"; | ||
uint result = Hashing.XXHash32.CalculateRaw(value, seed: 10); | ||
uint expected = Hashing.XXHash32.Calculate(Encoding.UTF8.GetBytes(value), seed: 10); | ||
Assert.NotEqual(expected, result); | ||
|
||
value = "abc"; | ||
result = Hashing.XXHash32.CalculateRaw(value, seed: 10); | ||
expected = Hashing.XXHash32.Calculate(Encoding.UTF8.GetBytes(value), seed: 10); | ||
Assert.NotEqual(expected, result); | ||
|
||
value = "κόσμε"; | ||
result = Hashing.XXHash32.CalculateRaw(value, seed: 10); | ||
expected = Hashing.XXHash32.Calculate(Encoding.UTF8.GetBytes(value), seed: 10); | ||
Assert.NotEqual(expected, result); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.