On Wed, May 6, 2009 at 12:35 PM, Thomas Müller <[email protected]> wrote: > My test case is: > > public static void main(String[] args) { > for (int i = 0; i < 3; i++) { > long start = System.currentTimeMillis(); > ArrayList list = new ArrayList(); > for (int j = 0; j < 1000000000; j++) { > list.size(); > } > System.out.println(System.currentTimeMillis() - start); > } > } > > With JDK 1.5 (Mac OS X): ArrayList declaration: 3028 List declaration: 8037
Interestingly, JDK 1.6 (Mac OS X) is much faster, both variants give ~1400. The results with 1.5 were the same as yours. But the really interesting thing is that with 1.6, the first of the 3 runs of the test in both variants only takes 12 to 14 ms. What kind of optimization could that be, which only works in the first run? Regards, Alex -- Alexander Klimetschek [email protected]
