1 package org.jgroups.tests; 2 3 6 import java.util.HashMap ; 7 import java.util.Map ; 8 import java.util.TreeMap ; 9 10 14 public class HashMapTest { 15 16 17 public static void main(String [] args) { 18 int num=10000; 19 for(int i=0; i < args.length; i++) { 20 if(args[i].equals("-num")) { 21 num=Integer.parseInt(args[++i]); 22 continue; 23 } 24 System.out.println("HashMapTest [-num <num>] [-help]"); 25 } 26 HashMapTest t=new HashMapTest(); 27 t.start(new HashMap (), num); 28 t.start(new TreeMap (), num); 29 System.out.println(""); 32 t.start(new HashMap (), num); 33 t.start(new TreeMap (), num); 34 } 37 38 63 64 private void start(Map m, int num) { 65 long start, stop; 66 67 start=System.currentTimeMillis(); 68 for(int i=0; i < num; i++) { 69 m.put(new Long (i), "bla"); 70 } 71 72 stop=System.currentTimeMillis(); 73 System.out.println("Took " + (stop-start) + "ms to insert " + m.size() + " elements into " + m.getClass().getName()); 74 m.clear(); 75 } 76 } 77 | Popular Tags |