diff options
| author | Jeroen van Rijn <Kelimion@users.noreply.github.com> | 2021-09-13 20:58:26 +0200 |
|---|---|---|
| committer | Jeroen van Rijn <Kelimion@users.noreply.github.com> | 2021-09-13 20:58:26 +0200 |
| commit | a641ef95c0f47cc172d6e3ca8ef8934a73f50081 (patch) | |
| tree | 24c909809c516a8b31e7d589399146c51f8486b3 /tests | |
| parent | e9b9d15de7bc08bdf2891586589e215832c9a3cc (diff) | |
Add XXH3-64 + tests.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/core/hash/test_core_hash.odin | 28 |
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 |