publicstaticvoidmain(String[] args)throws InterruptedException { // Test with Hashtable Object crunchifyHashTableObject = newHashtable<>(); crunchifyPerformTest(crunchifyHashTableObject);
// Test with synchronizedMap Object crunchifySynchronizedMapObject = Collections.synchronizedMap(newHashMap<String, Integer>()); crunchifyPerformTest(crunchifySynchronizedMapObject);
// Test with ConcurrentHashMap Object crunchifyConcurrentHashMapObject = newConcurrentHashMap<>(); crunchifyPerformTest(crunchifyConcurrentHashMapObject);
/** * 测试结果 Test start for:class java.util.Hashtable 2500K entried added/retrieved in 2953 ms 2500K entried added/retrieved in 4649 ms 2500K entried added/retrieved in 2736 ms 2500K entried added/retrieved in 2628 ms 2500K entried added/retrieved in 2621 ms For class java.util.Hashtable the average time is 3117 ms Test start for:class java.util.Collections$SynchronizedMap 2500K entried added/retrieved in 3036 ms 2500K entried added/retrieved in 2881 ms 2500K entried added/retrieved in 2692 ms 2500K entried added/retrieved in 3020 ms 2500K entried added/retrieved in 2806 ms For class java.util.Collections$SynchronizedMap the average time is 2887 ms Test start for:class java.util.concurrent.ConcurrentHashMap 2500K entried added/retrieved in 4378 ms 2500K entried added/retrieved in 1126 ms 2500K entried added/retrieved in 1008 ms 2500K entried added/retrieved in 935 ms 2500K entried added/retrieved in 1069 ms For class java.util.concurrent.ConcurrentHashMap the average time is 1703 ms */ }