@@ -0,0 +1,1679 @@
+package com.test.test2;%0A%0Aimport java.util.HashMap;%0Aimport java.util.Hashtable;%0Aimport java.util.Map;%0Aimport java.util.concurrent.TimeUnit;%0A%0Aimport org.openjdk.jmh.annotations.Benchmark;%0Aimport org.openjdk.jmh.annotations.BenchmarkMode;%0Aimport org.openjdk.jmh.annotations.Fork;%0Aimport org.openjdk.jmh.annotations.Measurement;%0Aimport org.openjdk.jmh.annotations.Mode;%0Aimport org.openjdk.jmh.annotations.OutputTimeUnit;%0Aimport org.openjdk.jmh.annotations.Warmup;%0A%0A@Measurement(iterations=2)%0A@Warmup(iterations=2)%0A@Fork(value=2)%0A@BenchmarkMode(Mode.AverageTime)%0A@OutputTimeUnit(TimeUnit.MICROSECONDS)%0Apublic class HashTableVSHashMap %7B%0A %0A%0A  %09    @Benchmark%0A%09    public void useHashmap()%0A%09    %7B%0A%09    %09Map map = new HashMap%3CString,String%3E();%0A%09%09%09useMap(map);%0A%09    %7D%0A%09    %0A%09    @Benchmark%0A%09    public void useHashtable()%0A%09    %7B%0A%09    %09Map map = new Hashtable%3CString,String%3E();%0A%09%09%09useMap(map);%0A%09    %7D%0A%0A%09%09private void useMap(Map map) %7B%0A%09%09%09int base = 100;%0A%09%09%09int insertions = 1* base;%0A%09%09%09int search = 4* base;%0A%09%09%09int range = 2* base;%0A%09%09%09insert(map,insertions,range);%0A%09%09%09search(map,range,search);%0A%09%09%7D%0A%09%09%0A%09%09public static int found = 0;%0A%09%09%0A%09%09private void search(Map map, int range, int search) %7B%0A%09%09%09for (int i =0;i%3Csearch;i++)%0A%09%09%09%7B%0A%09%09%09%09String key = String.valueOf((int)Math.random()*range);%0A%09%09%09%09%0A%09%09%09%09if(map.containsKey(key)) %0A%09%09%09%09%7B%0A%09%09%09%09%09found++;%0A%09%09%09%09%7D else %0A%09%09%09%09%7B%0A%09%09%09%09%09found--;%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%7D%0A%0A%09%09@SuppressWarnings(%22unchecked%22)%0A%09%09private void insert(Map map, int insertions, int range) %7B%0A%09%09%09for (int i=0;i%3Cinsertions;i++) %0A%09%09%09%7B%0A%09%09%09%09String key = String.valueOf((int)Math.random()*range);%0A%09%09%09%09String value = String.valueOf((int)Math.random()*range*1000);%0A%09%09%09%09map.put(key, value);%0A%09%09%09%7D%0A%09%09%7D%0A%09    %0A%09%7D%0A

Create HashTableVSHashMap.java