Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

perf comparison

By: a guest on Apr 2nd, 2013  |  syntax: Java  |  size: 0.62 KB  |  views: 27  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.     public static void main(String[] args) throws Exception {
  2.         int size = 10000000;
  3.         Vector<String> v = new Vector<String>(size);
  4.         ArrayList<String> a = new ArrayList<String>(size);
  5.         long a0 = System.nanoTime();
  6.         for(int i = 0; i < size; i++){
  7.             v.add("ASDF");
  8.         }
  9.         long a1 = System.nanoTime();
  10.         for(int i = 0; i < size; i++){
  11.             a.add("ASDF");
  12.         }
  13.         long a2 = System.nanoTime();
  14.         System.out.println("a1-a0:" + (a1-a0));
  15.         System.out.println("a2-a1:" + (a2-a1));
  16.     }
  17. //output:
  18. /*
  19. a1-a0:258077209
  20. a2-a1:76019664
  21. */