-
Notifications
You must be signed in to change notification settings - Fork 266
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
This reverts commit 984d49b.
- Loading branch information
1 parent
984d49b
commit f07f9d8
Showing
41 changed files
with
727 additions
and
1,678 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
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
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
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
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
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
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
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,53 @@ | ||
package benchmarks | ||
|
||
import ( | ||
"crypto" | ||
"fmt" | ||
"hash" | ||
"testing" | ||
|
||
"github.com/cosmos/iavl" | ||
"github.com/stretchr/testify/require" | ||
|
||
_ "crypto/sha256" | ||
|
||
_ "golang.org/x/crypto/ripemd160" // nolint: staticcheck // need to test ripemd160 | ||
_ "golang.org/x/crypto/sha3" | ||
) | ||
|
||
func BenchmarkHash(b *testing.B) { | ||
fmt.Printf("%s\n", iavl.GetVersionInfo()) | ||
hashers := []struct { | ||
name string | ||
size int | ||
hash hash.Hash | ||
}{ | ||
{"ripemd160", 64, crypto.RIPEMD160.New()}, | ||
{"ripemd160", 512, crypto.RIPEMD160.New()}, | ||
{"sha2-256", 64, crypto.SHA256.New()}, | ||
{"sha2-256", 512, crypto.SHA256.New()}, | ||
{"sha3-256", 64, crypto.SHA3_256.New()}, | ||
{"sha3-256", 512, crypto.SHA3_256.New()}, | ||
} | ||
|
||
for _, h := range hashers { | ||
prefix := fmt.Sprintf("%s-%d", h.name, h.size) | ||
hasher := h | ||
b.Run(prefix, func(sub *testing.B) { | ||
benchHasher(sub, hasher.hash, hasher.size) | ||
}) | ||
} | ||
} | ||
|
||
func benchHasher(b *testing.B, hash hash.Hash, size int) { | ||
// create all random bytes before to avoid timing this | ||
inputs := randBytes(b.N + size + 1) | ||
|
||
for i := 0; i < b.N; i++ { | ||
hash.Reset() | ||
// grab a slice of size bytes from random string | ||
_, err := hash.Write(inputs[i : i+size]) | ||
require.NoError(b, err) | ||
hash.Sum(nil) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.