From 30c46352b09cd2398d66e3172f0cd22ea2f1fc5f Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Sun, 23 Jul 2023 21:16:37 +0200 Subject: [PATCH] Improved benchmarks --- Benchmarks_test.go | 22 +++++++++++----------- README.md | 21 ++++++++++++++++++++- 2 files changed, 31 insertions(+), 12 deletions(-) diff --git a/Benchmarks_test.go b/Benchmarks_test.go index 97b5d6a..3ae16fc 100644 --- a/Benchmarks_test.go +++ b/Benchmarks_test.go @@ -8,17 +8,17 @@ import ( ) func BenchmarkSize(b *testing.B) { - b.Run("7", bench(7)) - b.Run("8", bench(8)) - b.Run("16", bench(16)) - b.Run("17", bench(17)) - b.Run("32", bench(32)) - b.Run("33", bench(33)) - b.Run("64", bench(64)) - b.Run("65", bench(65)) - b.Run("128", bench(128)) - b.Run("256", bench(256)) - b.Run("512", bench(512)) + b.Run(" 7", bench(7)) + b.Run(" 8", bench(8)) + b.Run(" 16", bench(16)) + b.Run(" 17", bench(17)) + b.Run(" 32", bench(32)) + b.Run(" 33", bench(33)) + b.Run(" 64", bench(64)) + b.Run(" 65", bench(65)) + b.Run(" 128", bench(128)) + b.Run(" 256", bench(256)) + b.Run(" 512", bench(512)) b.Run("1024", bench(1024)) b.Run("2048", bench(2048)) b.Run("4096", bench(4096)) diff --git a/README.md b/README.md index 5d7ee90..43e3370 100644 --- a/README.md +++ b/README.md @@ -8,4 +8,23 @@ This is a non-cryptographic hash (aka checksum) to verify data integrity. sum := hash.Bytes(data) ``` -You can use `strconv.FormatUint(sum, 16)` to get a string in hexadecimal format. \ No newline at end of file +You can use `strconv.FormatUint(sum, 16)` to get a string in hexadecimal format. + +## Benchmarks + +``` +BenchmarkSize/___7-12 144845362 8.282 ns/op +BenchmarkSize/___8-12 318401613 3.779 ns/op +BenchmarkSize/__16-12 273568264 4.400 ns/op +BenchmarkSize/__17-12 222336567 5.425 ns/op +BenchmarkSize/__32-12 191413396 6.266 ns/op +BenchmarkSize/__33-12 167791207 7.064 ns/op +BenchmarkSize/__64-12 224622992 5.320 ns/op +BenchmarkSize/__65-12 211713483 5.735 ns/op +BenchmarkSize/_128-12 137411010 8.735 ns/op +BenchmarkSize/_256-12 58641082 20.34 ns/op +BenchmarkSize/_512-12 22842753 54.89 ns/op +BenchmarkSize/1024-12 8913499 134.5 ns/op +BenchmarkSize/2048-12 4074927 294.5 ns/op +BenchmarkSize/4096-12 1952067 625.4 ns/op +``` \ No newline at end of file