99import java .util .concurrent .*;
1010
1111import static org .junit .Assert .assertEquals ;
12- import static org .junit .Assert .assertNotEquals ;
1312import static org .junit .Assert .assertTrue ;
1413
1514public class ConcurrentMapPerformanceTest {
@@ -24,11 +23,11 @@ public void givenMaps_whenGetPut500KTimes_thenConcurrentMapFaster() throws Excep
2423 long syncHashMapAvgRuntime = timeElapseForGetPut (synchronizedHashMap );
2524 long concurrentHashMapAvgRuntime = timeElapseForGetPut (concurrentHashMap );
2625
26+ System .out .println (String .format ("Hashtable: %s, syncHashMap: %s, ConcurrentHashMap: %s" , hashtableAvgRuntime , syncHashMapAvgRuntime , concurrentHashMapAvgRuntime ));
27+
2728 assertTrue (hashtableAvgRuntime > concurrentHashMapAvgRuntime );
2829 assertTrue (syncHashMapAvgRuntime > concurrentHashMapAvgRuntime );
2930
30- System .out .println (String .format ("Hashtable: %s, syncHashMap: %s, ConcurrentHashMap: %s" , hashtableAvgRuntime , syncHashMapAvgRuntime , concurrentHashMapAvgRuntime ));
31-
3231 }
3332
3433 private long timeElapseForGetPut (Map <String , Object > map ) throws InterruptedException {
@@ -90,7 +89,7 @@ public int hashCode() {
9089
9190 long mapOfDefaultHashDuration = System .currentTimeMillis () - defaultHashStartTime ;
9291 assertEquals (executeTimes * 2 , mapOfDefaultHash .size ());
93- assertNotEquals (executeTimes * 2 , mapOfSameHash .size ());
92+ assertEquals (executeTimes * 2 , mapOfSameHash .size ());
9493 System .out .println (String .format ("same-hash: %s, default-hash: %s" , mapOfSameHashDuration , mapOfDefaultHashDuration ));
9594 assertTrue ("same hashCode() should greatly degrade performance" , mapOfSameHashDuration > mapOfDefaultHashDuration * 10 );
9695 }
0 commit comments