31 lines
658 B
Go
31 lines
658 B
Go
package hash_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"git.marketally.com/tutus-one/tutus-chain/internal/random"
|
|
"git.marketally.com/tutus-one/tutus-chain/pkg/crypto/hash"
|
|
"git.marketally.com/tutus-one/tutus-chain/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) {
|
|
for t.Loop() {
|
|
tr, err := hash.NewMerkleTree(hashes)
|
|
require.NoError(t, err)
|
|
_ = tr.Root()
|
|
}
|
|
})
|
|
t.Run("CalcMerkleRoot", func(t *testing.B) {
|
|
for t.Loop() {
|
|
_ = hash.CalcMerkleRoot(hashes)
|
|
}
|
|
})
|
|
}
|