-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbench_test.go
38 lines (33 loc) · 1 KB
/
bench_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package sha1
import (
"crypto/sha1"
"testing"
)
// BenchmarkCustomSha1_2000 measures the performance of the Sum function for a 2000-byte input.
func BenchmarkCustomSha1_2000(b *testing.B) {
for i := 0; i < b.N; i++ {
randInput := randSeq(2000)
Sum([]byte(randInput))
}
}
// BenchmarkBuiltinSha1_2000 measures the performance of the built-in crypto/sha1 package for a 2000-byte input.
func BenchmarkBuiltinSha1_2000(b *testing.B) {
for i := 0; i < b.N; i++ {
randInput := randSeq(2000)
sha1.Sum([]byte(randInput))
}
}
// BenchmarkCustomSha1_20000 measures the performance of the Sum function for a 20000-byte input.
func BenchmarkCustomSha1_20000(b *testing.B) {
for i := 0; i < b.N; i++ {
randInput := randSeq(20000)
Sum([]byte(randInput))
}
}
// BenchmarkBuiltinSha1_20000 measures the performance of the built-in crypto/sha1 package for a 20000-byte input.
func BenchmarkBuiltinSha1_20000(b *testing.B) {
for i := 0; i < b.N; i++ {
randInput := randSeq(20000)
sha1.Sum([]byte(randInput))
}
}