I have a very simple unit test that just allocates a lot of Strings:
public class AllocationSpeedTest extends TestCase {
public void testAllocation() throws Exception {
for (int i = 0; i < 1000; i++) {
long startTime = System.currentTimeMillis();
String a = "dummy";
for (int j = 0; j < 1000; j++) {
a += "allocation driven";
}
System.out.println(i + ": " + (System.currentTimeMillis() - startTime) + "ms " + a.length());
}
}
}
On my Windows PC (Intel Core Duo, 2.2GHz, 2GB) this prints on average:
...
71: 47ms 17005
72: 47ms 17005
73: 46ms 17005
74: 47ms 17005
75: 47ms 17005
76: 47ms 17005
77: 47ms 17005
78: 47ms 17005
79: 47ms 17005
80: 62ms 17005
81: 47ms 17005
...
On SunOS (5.10 Generic_138888-03 sun4v sparc SUNW, SPARC-Enterprise-T5120):
...
786: 227ms 17005
787: 294ms 17005
788: 300ms 17005
789: 224ms 17005
790: 260ms 17005
791: 242ms 17005
792: 263ms 17005
793: 287ms 17005
794: 219ms 17005
795: 279ms 17005
796: 278ms 17005
797: 231ms 17005
798: 291ms 17005
799: 246ms 17005
800: 327ms 17005
...
JDK version is 1.4.2_18 on both machines. JVM parameters are the same and are:
–server –Xmx256m –Xms256m
Can anyone explain why SUN super server is slower?
(http://www.sun.com/servers/coolthreads/t5120/performance.xml)
The CPU is indeed slower on SPARC (1.2Ghz) and as answered by one of the Sun’s engineers T2 is usualy 3 times slower for single-threaded application than modern Intel processors. Though, he also stated that in a multi-threaded environment SPARC should be faster.
I have made a multi-threaded test using GroboUtils library and tested both allocations (through concatenations) and simple calculations ( a += j*j ) to test processor. And I’ve got the following results:
SPARC shows its power here by outperforming Intel on 100 threads.
Here goes the multi-threaded calculation test:
Here goes the multi-threaded allocation test: