mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-29 13:41:47 +00:00
8f45d57612
Mostly this switches to math/rand/v2, but sometimes randomness is not really needed. Signed-off-by: Roman Khimov <roman@nspcc.ru>
32 lines
677 B
Go
32 lines
677 B
Go
package hash_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/nspcc-dev/neo-go/internal/random"
|
|
"github.com/nspcc-dev/neo-go/pkg/crypto/hash"
|
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func BenchmarkMerkle(t *testing.B) {
|
|
var hashes = make([]util.Uint256, 100000)
|
|
for i := range hashes {
|
|
hashes[i] = random.Uint256()
|
|
}
|
|
|
|
t.Run("NewMerkleTree", func(t *testing.B) {
|
|
t.ResetTimer()
|
|
for n := 0; n < t.N; n++ {
|
|
tr, err := hash.NewMerkleTree(hashes)
|
|
require.NoError(t, err)
|
|
_ = tr.Root()
|
|
}
|
|
})
|
|
t.Run("CalcMerkleRoot", func(t *testing.B) {
|
|
t.ResetTimer()
|
|
for n := 0; n < t.N; n++ {
|
|
_ = hash.CalcMerkleRoot(hashes)
|
|
}
|
|
})
|
|
}
|