cmd/syncthing, lib/sha256: Skip CPU benchmarks when user decided (fixes #4348)

When STHASHING is set, don't benchmark as it's already decided. If weak
hashing isn't set to "auto", don't benchmark that either.

GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/4349
This commit is contained in:
Jakob Borg
2017-09-06 06:55:47 +00:00
committed by Audrius Butkevicius
parent 9dbc509996
commit 4d3e0de4ba
2 changed files with 13 additions and 10 deletions

View File

@@ -55,17 +55,13 @@ func SelectAlgo() {
}
case "minio":
// When set to "minio", use that. Benchmark anyway to be able to
// present the difference.
benchmark()
// When set to "minio", use that.
selectMinio()
default:
// When set to anything else, such as "standard", use the default Go
// implementation. Benchmark that anyway, so we can report something
// useful in Report(). Make sure not to touch the minio
// implementation. Make sure not to touch the minio
// implementation as it may be disabled for incompatibility reasons.
cryptoPerf = cpuBenchOnce(benchmarkingIterations*benchmarkingDuration, cryptoSha256.New)
}
verifyCorrectness()
@@ -89,6 +85,10 @@ func Report() {
otherImpl = defaultImpl
}
if selectedRate == 0 {
return
}
l.Infof("Single thread SHA256 performance is %s using %s (%s using %s).", formatRate(selectedRate), selectedImpl, formatRate(otherRate), otherImpl)
}