my results:
java 6 client
[forward1] for(int i=0;i<a.size();i++)
best:0.236861869s
avg :0.237710407s
[forward2] int size=a.size();for(int i=0;i<size;i++)
best:0.243388188s
avg :0.245275719s
[reverse1] for(int i=a.size()-1;i>=0;--i)
best:0.234105232s
avg :0.236468176s
[reverse2] for(int i=a.size();--i>=0;)
best:0.234173636s
avg :0.23560745s
[iterate] for(Iterator i=a.iterator();i.hasNext();)
best:1.001008995s
avg :1.002553588s
[foreach] for(Integer s: a)
best:1.001137343s
avg :1.002832611s
[synchro1] for(Iterator<Integer> i = sa.iterator(); i.hasNext();) // one synchronizedList() call
best:1.047498371s
avg :1.050345237s
[synchro2] for(Iterator<Integer> i = sa.iterator(); i.hasNext();) // multiple synchronizedList() calls (one per test iteration)
best:1.026651229s
avg :1.034549709s
java 7b12 client
[forward1] for(int i=0;i<a.size();i++)
best:0.098598338s
avg :0.099309703s
[forward2] int size=a.size();for(int i=0;i<size;i++)
best:0.086764429s
avg :0.087365481s
[reverse1] for(int i=a.size()-1;i>=0;--i)
best:0.086961825s
avg :0.087888956s
[reverse2] for(int i=a.size();--i>=0;)
best:0.087148515s
avg :0.087648407s
[iterate] for(Iterator i=a.iterator();i.hasNext();)
best:0.902982435s
avg :0.9046512s
[foreach] for(Integer s: a)
best:0.901919269s
avg :0.904204496s
[synchro1] for(Iterator<Integer> i = sa.iterator(); i.hasNext();) // one synchronizedList() call
best:0.88929315s
avg :0.898148557s
[synchro2] for(Iterator<Integer> i = sa.iterator(); i.hasNext();) // multiple synchronizedList() calls (one per test iteration)
best:0.887476421s
avg :0.901809679s
java 6 server
[forward1] for(int i=0;i<a.size();i++)
best:0.047897427s
avg :0.04833437s
[forward2] int size=a.size();for(int i=0;i<size;i++)
best:0.047876021s
avg :0.048443501s
[reverse1] for(int i=a.size()-1;i>=0;--i)
best:0.050514161s
avg :0.051226223s
[reverse2] for(int i=a.size();--i>=0;)
best:0.050541038s
avg :0.051425828s
[iterate] for(Iterator i=a.iterator();i.hasNext();)
best:0.170091701s
avg :0.171224648s
[foreach] for(Integer s: a)
best:0.17041104s
avg :0.171149453s
[synchro1] for(Iterator<Integer> i = sa.iterator(); i.hasNext();) // one synchronizedList() call
best:0.170544356s
avg :0.171396083s
[synchro2] for(Iterator<Integer> i = sa.iterator(); i.hasNext();) // multiple synchronizedList() calls (one per test iteration)
best:0.169996068s
avg :0.17115992s
java 7b12 server (tiered compiler)
[forward1] for(int i=0;i<a.size();i++)
best:0.046119653s
avg :0.046703256s
[forward2] int size=a.size();for(int i=0;i<size;i++)
best:0.046233412s
avg :0.046704791s
[reverse1] for(int i=a.size()-1;i>=0;--i)
best:0.048204308s
avg :0.048780098s
[reverse2] for(int i=a.size();--i>=0;)
best:0.048143243s
avg :0.048854144s
[iterate] for(Iterator i=a.iterator();i.hasNext();)
best:0.078269895s
avg :0.07890705s
[foreach] for(Integer s: a)
best:0.078561754s
avg :0.079460743s
[synchro1] for(Iterator<Integer> i = sa.iterator(); i.hasNext();) // one synchronizedList() call
best:0.074725515s
avg :0.076259373s
[synchro2] for(Iterator<Integer> i = sa.iterator(); i.hasNext();) // multiple synchronizedList() calls (one per test iteration)
best:0.079357871s
avg :0.080087159s
CPU: Core2Duo; 64bit winXP; 32bit VMs
I did the test primary because I was curious how the tiered compiler performs compared to the old server VM.
Because i always use the server VM for my 3D stuff, i will use the plain old for loop (for(int i=0;i<a.size();i++) )in future too. But the really interesting part of this benchmark:
-the 7 client VM solves the for loop 2x faster then the 6
-the new tiered VM is even a little bit faster then the old server VM