@ -9,7 +9,7 @@ import java.io.File
*/
*/
class HashServiceTest extends BaseTest {
class HashServiceTest extends BaseTest {
def benchmarkDH ashTestCase( filePath : String ) : Long = {
def dh ashTestCase( filePath : String ) : Long = {
val sample = new File ( filePath )
val sample = new File ( filePath )
val image = ImageIO . read ( sample )
val image = ImageIO . read ( sample )
HashService . getDhash ( image )
HashService . getDhash ( image )
@ -18,27 +18,27 @@ class HashServiceTest extends BaseTest {
test ( "Benchmark DHash" ) {
test ( "Benchmark DHash" ) {
info ( "Benchmarking DHash" )
info ( "Benchmarking DHash" )
info ( "DHash Large Image 3684x2736" )
info ( "DHash Large Image 3684x2736" )
val largeTime1 = getTime { benchmarkDH ashTestCase( TestParams . LargeSampleImage1 ) }
val largeTime2 = getTime { benchmarkDH ashTestCase( TestParams . LargeSampleImage1 ) }
val largeTime3 = getTime { benchmarkDH ashTestCase( TestParams . LargeSampleImage1 ) }
val largeTime4 = getTime { benchmarkDH ashTestCase( TestParams . LargeSampleImage1 ) }
val largeTime5 = getTime { benchmarkDH ashTestCase( TestParams . LargeSampleImage1 ) }
val largeTime1 = getTime { dh ashTestCase( TestParams . LargeSampleImage1 ) }
val largeTime2 = getTime { dh ashTestCase( TestParams . LargeSampleImage1 ) }
val largeTime3 = getTime { dh ashTestCase( TestParams . LargeSampleImage1 ) }
val largeTime4 = getTime { dh ashTestCase( TestParams . LargeSampleImage1 ) }
val largeTime5 = getTime { dh ashTestCase( TestParams . LargeSampleImage1 ) }
val largeMean = getMean ( largeTime1 , largeTime2 , largeTime3 , largeTime4 , largeTime5 )
val largeMean = getMean ( largeTime1 , largeTime2 , largeTime3 , largeTime4 , largeTime5 )
info ( s" The mean time of 5 tests for large was: $largeMean ms " )
info ( s" The mean time of 5 tests for large was: $largeMean ms " )
info ( "DHash Medium Image 1824x1368" )
info ( "DHash Medium Image 1824x1368" )
val mediumTime1 = getTime { benchmarkDH ashTestCase( TestParams . MediumSampleImage1 ) }
val mediumTime2 = getTime { benchmarkDH ashTestCase( TestParams . MediumSampleImage1 ) }
val mediumTime3 = getTime { benchmarkDH ashTestCase( TestParams . MediumSampleImage1 ) }
val mediumTime4 = getTime { benchmarkDH ashTestCase( TestParams . MediumSampleImage1 ) }
val mediumTime5 = getTime { benchmarkDH ashTestCase( TestParams . MediumSampleImage1 ) }
val mediumTime1 = getTime { dh ashTestCase( TestParams . MediumSampleImage1 ) }
val mediumTime2 = getTime { dh ashTestCase( TestParams . MediumSampleImage1 ) }
val mediumTime3 = getTime { dh ashTestCase( TestParams . MediumSampleImage1 ) }
val mediumTime4 = getTime { dh ashTestCase( TestParams . MediumSampleImage1 ) }
val mediumTime5 = getTime { dh ashTestCase( TestParams . MediumSampleImage1 ) }
val mediumMean = getMean ( mediumTime1 , mediumTime2 , mediumTime3 , mediumTime4 , mediumTime5 )
val mediumMean = getMean ( mediumTime1 , mediumTime2 , mediumTime3 , mediumTime4 , mediumTime5 )
info ( s" The mean time of 5 tests for medium was: $mediumMean ms " )
info ( s" The mean time of 5 tests for medium was: $mediumMean ms " )
info ( "DHash Small Image 912x684" )
info ( "DHash Small Image 912x684" )
val smallTime1 = getTime { benchmarkDH ashTestCase( TestParams . SmallSampleImage1 ) }
val smallTime2 = getTime { benchmarkDH ashTestCase( TestParams . SmallSampleImage1 ) }
val smallTime3 = getTime { benchmarkDH ashTestCase( TestParams . SmallSampleImage1 ) }
val smallTime4 = getTime { benchmarkDH ashTestCase( TestParams . SmallSampleImage1 ) }
val smallTime5 = getTime { benchmarkDH ashTestCase( TestParams . SmallSampleImage1 ) }
val smallTime1 = getTime { dh ashTestCase( TestParams . SmallSampleImage1 ) }
val smallTime2 = getTime { dh ashTestCase( TestParams . SmallSampleImage1 ) }
val smallTime3 = getTime { dh ashTestCase( TestParams . SmallSampleImage1 ) }
val smallTime4 = getTime { dh ashTestCase( TestParams . SmallSampleImage1 ) }
val smallTime5 = getTime { dh ashTestCase( TestParams . SmallSampleImage1 ) }
val smallMean = getMean ( smallTime1 , smallTime2 , smallTime3 , smallTime4 , smallTime5 )
val smallMean = getMean ( smallTime1 , smallTime2 , smallTime3 , smallTime4 , smallTime5 )
info ( s" The mean time of 5 tests for small was: $smallMean ms " )
info ( s" The mean time of 5 tests for small was: $smallMean ms " )
assert ( true )
assert ( true )
@ -76,5 +76,14 @@ class HashServiceTest extends BaseTest {
debug ( s" Testing that $hash = -5198299688551933030L " )
debug ( s" Testing that $hash = -5198299688551933030L " )
assert ( hash == - 5198299688551933030L )
assert ( hash == - 5198299688551933030L )
}
}
test ( "DHash Of Large, Medium, And Small Sample 1 Must Be Similar" ) {
val largeHash = dhashTestCase ( TestParams . LargeSampleImage1 )
val mediumHash = dhashTestCase ( TestParams . MediumSampleImage1 )
val smallHash = dhashTestCase ( TestParams . SmallSampleImage1 )
assert ( HashService . areDhashSimilar ( largeHash , mediumHash ) )
assert ( HashService . areDhashSimilar ( largeHash , smallHash ) )
assert ( HashService . areDhashSimilar ( mediumHash , smallHash ) )
}
}
}