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

package com.sothr.imagetools.hash
import scala.collection.mutable
class HashServiceMD5Test extends HashServiceBaseTest {
def md5TestCase(filePath: String): String = {
HashService.getMD5(filePath)
}
test("Calculate MD5 Large Sample Image 1") {
debug("Starting 'Calculate MD5 Large Sample Image 1' test")
val hash = HashService.getMD5(LargeSampleImage1)
debug(s"Testing that $hash = 3fbccfd5faf3f991435b827ee5961862")
assert(hash == "3fbccfd5faf3f991435b827ee5961862")
}
test("Calculate MD5 Medium Sample Image 1") {
debug("Starting 'Calculate MD5 Medium Sample Image 1' test")
val hash = HashService.getMD5(MediumSampleImage1)
debug(s"Testing that $hash = a95e2cc4610307eb957e9c812429c53e")
assert(hash == "a95e2cc4610307eb957e9c812429c53e")
}
test("Calculate MD5 Small Sample Image 1") {
debug("Starting 'Calculate MD5 Small Sample Image 1' test")
val hash = HashService.getMD5(SmallSampleImage1)
debug(s"Testing that $hash = b137131bd55896c747286e4d247b845e")
assert(hash == "b137131bd55896c747286e4d247b845e")
}
test("Benchmark MD5") {
info("Benchmarking MD5")
info("MD5 Large Image 3684x2736")
val time = new mutable.MutableList[Long]()
for (_ <- 0 until benchmarkRuns) {
time += getTime {
md5TestCase(LargeSampleImage1)
}
}
val largeMean = getMean(time.toArray[Long])
info(s"The mean time of ${time.size} tests for large was: $largeMean ms")
time.clear()
info("MD5 Medium Image 1824x1368")
for (_ <- 0 until benchmarkRuns) {
time += getTime {
md5TestCase(MediumSampleImage1)
}
}
val mediumMean = getMean(time.toArray[Long])
info(s"The mean time of ${time.size} tests for medium was: $mediumMean ms")
time.clear()
info("MD5 Small Image 912x684")
for (_ <- 0 until benchmarkRuns) {
time += getTime {
md5TestCase(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)
}
}