@@ -33,8 +33,8 @@ public static List<Tuple<string, string, double>> GetSimilarity(
3333 {
3434 throw new DirectoryNotFoundException ( "Directory not found." ) ;
3535 }
36- Debug . WriteLine ( $ "Hash Algorithm : { hashEnum } \n Precision : { precision } \n " +
37- $ "Interpolation Mode : { interpolationMode } \n Threshold : { threshold } %") ;
36+ Debug . WriteLine ( $ "HashAlgorithm : { hashEnum } Precision : { precision } \n " +
37+ $ "InterpolationMode : { interpolationMode } Threshold : { threshold } %") ;
3838
3939 watch . Restart ( ) ;
4040
@@ -62,7 +62,7 @@ public static List<Tuple<string, string, double>> GetSimilarity(
6262 watch . Restart ( ) ;
6363
6464 // Compare hashes
65- var tuples = new List < Tuple < string , string , double > > ( ) ;
65+ var tuples = new ConcurrentBag < Tuple < string , string , double > > ( ) ;
6666 Parallel . For ( 0 , imageHashPairs . Length , i =>
6767 {
6868 for ( int j = imageHashPairs . Length - 1 ; j > i ; j -- )
@@ -81,9 +81,10 @@ public static List<Tuple<string, string, double>> GetSimilarity(
8181 watch . Stop ( ) ;
8282 long compareTime = watch . ElapsedMilliseconds ;
8383 Debug . WriteLine ( $ "GetHash: { hashTime } ms; CompareHash: { compareTime } ms") ;
84+ Debug . WriteLine ( "TuplesCount:" + tuples . Count ) ;
8485
8586 // Sort by similarity
86- return tuples . OrderByDescending ( u => u . Item3 ) . ToList ( ) ; // TODO: seldom u=null.
87+ return tuples . OrderByDescending ( u => u . Item3 ) . ToList ( ) ;
8788 }
8889
8990 public enum HashEnum
@@ -100,7 +101,7 @@ private static KeyValuePair<string, string>[] GetImageHashes(string folderPath,
100101 var imageNames = from file in di . GetFiles ( )
101102 where imageExtensions . Contains ( file . Extension )
102103 select file . FullName ;
103- Debug . WriteLine ( $ "Directory: { folderPath } \n Image count : { imageNames . Count ( ) } ") ;
104+ Debug . WriteLine ( $ "Directory: { folderPath } ; ImageCount : { imageNames . Count ( ) } ") ;
104105 if ( imageNames . Count ( ) < 2 ) { return null ; }
105106
106107 // Get hash algorithm
@@ -137,7 +138,7 @@ where imageExtensions.Contains(file.Extension)
137138 } ) ;
138139
139140 watch . Stop ( ) ;
140- Debug . WriteLine ( $ "Valid count : { imageHashPairs . Count } elapsed time : { watch . ElapsedMilliseconds } ms") ;
141+ Debug . WriteLine ( $ "ValidCount : { imageHashPairs . Count } ; ElapsedTime : { watch . ElapsedMilliseconds } ms") ;
141142 return imageHashPairs . ToArray ( ) ;
142143 }
143144
0 commit comments