You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
2.0 KiB
67 lines
2.0 KiB
package com.sothr.imagetools.hash
|
|
|
|
import scala.collection.mutable
|
|
|
|
class HashServiceSHA1Test extends HashServiceBaseTest {
|
|
|
|
def sha1TestCase(filePath: String): String = {
|
|
HashService.getSHA1(filePath)
|
|
}
|
|
|
|
test("Calculate SHA1 Large Sample Image 1") {
|
|
debug("Starting 'Calculate SHA1 Large Sample Image 1' test")
|
|
val hash = HashService.getSHA1(LargeSampleImage1)
|
|
debug(s"Testing that $hash = 4beb6f2d852b75a313863916a1803ebad13a3196")
|
|
assert(hash == "4beb6f2d852b75a313863916a1803ebad13a3196")
|
|
}
|
|
|
|
test("Calculate SHA1 Medium Sample Image 1") {
|
|
debug("Starting 'Calculate SHA1 Medium Sample Image 1' test")
|
|
val hash = HashService.getSHA1(MediumSampleImage1)
|
|
debug(s"Testing that $hash = edc718ce8e3556a39592ffdc214d0f636529be9f")
|
|
assert(hash == "edc718ce8e3556a39592ffdc214d0f636529be9f")
|
|
}
|
|
|
|
test("Calculate SHA1 Small Sample Image 1") {
|
|
debug("Starting 'Calculate SHA1 Small Sample Image 1' test")
|
|
val hash = HashService.getSHA1(SmallSampleImage1)
|
|
debug(s"Testing that $hash = 1a91d2b5327f0aad258419f76b87d4c0bc343443")
|
|
assert(hash == "1a91d2b5327f0aad258419f76b87d4c0bc343443")
|
|
}
|
|
|
|
test("Benchmark SHA1") {
|
|
info("Benchmarking SHA1")
|
|
info("SHA1 Large Image 3684x2736")
|
|
val time = new mutable.MutableList[Long]()
|
|
for (_ <- 0 until benchmarkRuns) {
|
|
time += getTime {
|
|
sha1TestCase(LargeSampleImage1)
|
|
}
|
|
}
|
|
|
|
val largeMean = getMean(time.toArray[Long])
|
|
info(s"The mean time of ${time.size} tests for large was: $largeMean ms")
|
|
time.clear()
|
|
info("SHA1 Medium Image 1824x1368")
|
|
for (_ <- 0 until benchmarkRuns) {
|
|
time += getTime {
|
|
sha1TestCase(MediumSampleImage1)
|
|
}
|
|
}
|
|
|
|
val mediumMean = getMean(time.toArray[Long])
|
|
info(s"The mean time of ${time.size} tests for medium was: $mediumMean ms")
|
|
time.clear()
|
|
info("SHA1 Small Image 912x684")
|
|
for (_ <- 0 until benchmarkRuns) {
|
|
time += getTime {
|
|
sha1TestCase(SmallSampleImage1)
|
|
}
|
|
}
|
|
|
|
val smallMean = getMean(time.toArray[Long])
|
|
info(s"The mean time of ${time.size} tests for small was: $smallMean ms")
|
|
time.clear()
|
|
assert(true)
|
|
}
|
|
}
|