mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-06-13 01:26:43 +00:00

* Replace keccak with CSHAKE256 in oPoW * Add benchmarks to hash writers to compare blake2b to the CSHAKE * Update genesis blocks * Update tests * Define genesis's block level to be the maximal one * Add message to genesis coinbase * Add comments to genesis coinbase * Fix tests Co-authored-by: Ori Newman <orinewman1@gmail.com>
51 lines
1.1 KiB
Go
51 lines
1.1 KiB
Go
package hashes
|
|
|
|
import (
|
|
"math/rand"
|
|
"testing"
|
|
)
|
|
|
|
func BenchmarkNewBlockHashWriterSmall(b *testing.B) {
|
|
r := rand.New(rand.NewSource(0))
|
|
var someBytes [32]byte
|
|
r.Read(someBytes[:])
|
|
for i := 0; i < b.N; i++ {
|
|
hasher := NewBlockHashWriter()
|
|
hasher.InfallibleWrite(someBytes[:])
|
|
hasher.Finalize()
|
|
}
|
|
}
|
|
|
|
func BenchmarkNewBlockHashWriterBig(b *testing.B) {
|
|
r := rand.New(rand.NewSource(0))
|
|
var someBytes [1024]byte
|
|
r.Read(someBytes[:])
|
|
for i := 0; i < b.N; i++ {
|
|
hasher := NewBlockHashWriter()
|
|
hasher.InfallibleWrite(someBytes[:])
|
|
hasher.Finalize()
|
|
}
|
|
}
|
|
|
|
func BenchmarkNewHeavyHashWriterSmall(b *testing.B) {
|
|
r := rand.New(rand.NewSource(0))
|
|
var someBytes [32]byte
|
|
r.Read(someBytes[:])
|
|
for i := 0; i < b.N; i++ {
|
|
hasher := NewHeavyHashWriter()
|
|
hasher.InfallibleWrite(someBytes[:])
|
|
hasher.Finalize()
|
|
}
|
|
}
|
|
|
|
func BenchmarkNewHeavyHashWriterBig(b *testing.B) {
|
|
r := rand.New(rand.NewSource(0))
|
|
var someBytes [1024]byte
|
|
r.Read(someBytes[:])
|
|
for i := 0; i < b.N; i++ {
|
|
hasher := NewHeavyHashWriter()
|
|
hasher.InfallibleWrite(someBytes[:])
|
|
hasher.Finalize()
|
|
}
|
|
}
|