| 123456789101112131415161718192021222324252627282930313233343536373839 |
- package benchmark
- import (
- "testing"
- )
- var (
- str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- )
- func BenchmarkHash(b *testing.B) {
- for i := 0; i < b.N; i++ {
- Hash([]byte(str))
- }
- }
- func BenchmarkHash2(b *testing.B) {
- for i := 0; i < b.N; i++ {
- Hash2([]byte(str))
- }
- }
- // Concurrent
- func BenchmarkHashParallel(b *testing.B) {
- b.RunParallel(func(pb *testing.PB) {
- for pb.Next() {
- Hash([]byte(str))
- }
- })
- }
- // Concurrent
- func BenchmarkHash2Parallel(b *testing.B) {
- b.RunParallel(func(pb *testing.PB) {
- for pb.Next() {
- Hash2([]byte(str))
- }
- })
- }
|