aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJeroen van Rijn <Kelimion@users.noreply.github.com>2021-09-13 20:58:26 +0200
committerJeroen van Rijn <Kelimion@users.noreply.github.com>2021-09-13 20:58:26 +0200
commita641ef95c0f47cc172d6e3ca8ef8934a73f50081 (patch)
tree24c909809c516a8b31e7d589399146c51f8486b3 /tests
parente9b9d15de7bc08bdf2891586589e215832c9a3cc (diff)
Add XXH3-64 + tests.
Diffstat (limited to 'tests')
-rw-r--r--tests/core/hash/test_core_hash.odin28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/core/hash/test_core_hash.odin b/tests/core/hash/test_core_hash.odin
index 0189ccfe3..74884dd68 100644
--- a/tests/core/hash/test_core_hash.odin
+++ b/tests/core/hash/test_core_hash.odin
@@ -79,6 +79,19 @@ benchmark_xxh64 :: proc(options: ^time.Benchmark_Options, allocator := context.a
return nil
}
+benchmark_xxh3_64 :: proc(options: ^time.Benchmark_Options, allocator := context.allocator) -> (err: time.Benchmark_Error) {
+ buf := options.input
+
+ h: u64
+ for _ in 0..=options.rounds {
+ h = xxhash.XXH3_64(buf)
+ }
+ options.count = options.rounds
+ options.processed = options.rounds * options.bytes
+ options.hash = u128(h)
+ return nil
+}
+
benchmark_xxh3_128 :: proc(options: ^time.Benchmark_Options, allocator := context.allocator) -> (err: time.Benchmark_Error) {
buf := options.input
@@ -143,6 +156,21 @@ test_benchmark_runner :: proc(t: ^testing.T) {
expect(t, options.hash == 0x87d2a1b6e1163ef1, name)
benchmark_print(name, options)
+ name = "XXH3_64 100 zero bytes"
+ options.bytes = 100
+ options.bench = benchmark_xxh3_64
+ err = time.benchmark(options, context.allocator)
+ expect(t, err == nil, name)
+ expect(t, options.hash == 0x801fedc74ccd608c, name)
+ benchmark_print(name, options)
+
+ name = "XXH3_64 1 MiB zero bytes"
+ options.bytes = 1_048_576
+ err = time.benchmark(options, context.allocator)
+ expect(t, err == nil, name)
+ expect(t, options.hash == 0x918780b90550bf34, name)
+ benchmark_print(name, options)
+
name = "XXH3_128 100 zero bytes"
options.bytes = 100
options.bench = benchmark_xxh3_128