-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
number571
committed
Nov 17, 2024
1 parent
ed84583
commit 81e2a7c
Showing
4 changed files
with
42 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package hashing | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
|
||
testutils "github.com/number571/go-peer/test/utils" | ||
) | ||
|
||
/* | ||
goos: linux | ||
goarch: amd64 | ||
pkg: github.com/number571/go-peer/pkg/crypto/hashing | ||
cpu: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz | ||
BenchmarkHasher-12 1000000 268.5 ns/op | ||
--- BENCH: BenchmarkHasher-12 | ||
hashing_bench_test.go:37: Timer (N=1): 717ns | ||
hashing_bench_test.go:37: Timer (N=1000000): 268.460938ms | ||
PASS | ||
*/ | ||
|
||
// go test -bench=BenchmarkHasher -benchtime=1000000x -timeout 99999s | ||
func BenchmarkHasher(b *testing.B) { | ||
b.StopTimer() | ||
randomBytes := testutils.PseudoRandomBytes(int(time.Now().UnixNano())) | ||
b.StartTimer() | ||
|
||
now := time.Now() | ||
for i := 0; i < b.N; i++ { | ||
_ = NewHasher(randomBytes).ToBytes() | ||
} | ||
end := time.Since(now) | ||
|
||
b.Logf("Timer (N=%d): %s", b.N, end) | ||
} |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.