mirror of
https://github.com/golang/go
synced 2024-11-26 10:38:07 -07:00
crypto/sha256, crypto/sha512: 1.3x speedup
SHA-256: benchmark old ns/op new ns/op delta BenchmarkHash1K 21686 16912 -22.01% BenchmarkHash8K 173216 135020 -22.05% benchmark old MB/s new MB/s speedup BenchmarkHash1K 47.22 60.55 1.28x BenchmarkHash8K 47.29 60.67 1.28x SHA-512: benchmark old ns/op new ns/op delta BenchmarkHash1K 14323 11163 -22.06% BenchmarkHash8K 114120 88693 -22.28% benchmark old MB/s new MB/s speedup BenchmarkHash1K 71.49 91.73 1.28x BenchmarkHash8K 71.78 92.36 1.29x R=golang-dev, agl CC=golang-dev https://golang.org/cl/6584071
This commit is contained in:
parent
23599ca2f6
commit
b459afe843
@ -86,10 +86,10 @@ func block(dig *digest, p []byte) {
|
||||
w[i] = uint32(p[j])<<24 | uint32(p[j+1])<<16 | uint32(p[j+2])<<8 | uint32(p[j+3])
|
||||
}
|
||||
for i := 16; i < 64; i++ {
|
||||
t1 := (w[i-2]>>17 | w[i-2]<<(32-17)) ^ (w[i-2]>>19 | w[i-2]<<(32-19)) ^ (w[i-2] >> 10)
|
||||
|
||||
t2 := (w[i-15]>>7 | w[i-15]<<(32-7)) ^ (w[i-15]>>18 | w[i-15]<<(32-18)) ^ (w[i-15] >> 3)
|
||||
|
||||
v1 := w[i-2]
|
||||
t1 := (v1>>17 | v1<<(32-17)) ^ (v1>>19 | v1<<(32-19)) ^ (v1 >> 10)
|
||||
v2 := w[i-15]
|
||||
t2 := (v2>>7 | v2<<(32-7)) ^ (v2>>18 | v2<<(32-18)) ^ (v2 >> 3)
|
||||
w[i] = t1 + w[i-7] + t2 + w[i-16]
|
||||
}
|
||||
|
||||
|
@ -101,9 +101,10 @@ func block(dig *digest, p []byte) {
|
||||
uint64(p[j+4])<<24 | uint64(p[j+5])<<16 | uint64(p[j+6])<<8 | uint64(p[j+7])
|
||||
}
|
||||
for i := 16; i < 80; i++ {
|
||||
t1 := (w[i-2]>>19 | w[i-2]<<(64-19)) ^ (w[i-2]>>61 | w[i-2]<<(64-61)) ^ (w[i-2] >> 6)
|
||||
|
||||
t2 := (w[i-15]>>1 | w[i-15]<<(64-1)) ^ (w[i-15]>>8 | w[i-15]<<(64-8)) ^ (w[i-15] >> 7)
|
||||
v1 := w[i-2]
|
||||
t1 := (v1>>19 | v1<<(64-19)) ^ (v1>>61 | v1<<(64-61)) ^ (v1 >> 6)
|
||||
v2 := w[i-15]
|
||||
t2 := (v2>>1 | v2<<(64-1)) ^ (v2>>8 | v2<<(64-8)) ^ (v2 >> 7)
|
||||
|
||||
w[i] = t1 + w[i-7] + t2 + w[i-16]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user