Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
number571 committed Nov 17, 2024
1 parent ed84583 commit 81e2a7c
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 10 deletions.
35 changes: 35 additions & 0 deletions pkg/crypto/hashing/hashing_bench_test.go
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)
}
3 changes: 0 additions & 3 deletions pkg/crypto/hashing/hashing_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package hashing

import (
"fmt"
"testing"
)

Expand All @@ -21,8 +20,6 @@ func TestHasher(t *testing.T) {
t.Error("bit didn't change the result ")
return
}

fmt.Println(hash)
}

func TestHMACSHasher(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion test/result/badge_codelines.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 6 additions & 6 deletions test/result/coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 81e2a7c

Please sign in to comment.