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:
1 thread : Intel : Calculations test : 43ms
100 threads : Intel : Calculations test : 225ms
1 thread : Intel : Allocations test : 35ms
100 threads : Intel : Allocations test : 1754ms
1 thread : SPARC : Calculations test : 197ms
100 threads : SPARC : Calculations test : 261ms
1 thread : SPARC : Allocations test : 236ms
100 threads : SPARC : Allocations test : 1517ms
SPARC shows its power here by outperforming Intel on 100 threads.
Here goes the multi-threaded calculation test:
import java.util.ArrayList;
import java.util.List;
import net.sourceforge.groboutils.junit.v1.MultiThreadedTestRunner;
import net.sourceforge.groboutils.junit.v1.TestRunnable;
import junit.framework.TestCase;
public class TM1_CalculationSpeedTest extends TestCase {
public void testCalculation() throws Throwable {
List threads = new ArrayList();
for (int i = 0; i < 100; i++) {
threads.add(new Requester());
}
MultiThreadedTestRunner mttr = new MultiThreadedTestRunner((TestRunnable[]) threads.toArray(new TestRunnable[threads.size()]));
mttr.runTestRunnables(2 * 60 * 1000);
}
public class Requester extends TestRunnable {
public void runTest() throws Exception {
long startTime = System.currentTimeMillis();
long a = 0;
for (int j = 0; j < 10000000; j++) {
a += j * j;
}
long endTime = System.currentTimeMillis();
System.out.println(this + ": " + (endTime - startTime) + "ms " + a);
}
}
}
Here goes the multi-threaded allocation test:
import java.util.ArrayList;
import java.util.List;
import junit.framework.TestCase;
import net.sourceforge.groboutils.junit.v1.MultiThreadedTestRunner;
import net.sourceforge.groboutils.junit.v1.TestRunnable;
public class TM2_AllocationSpeedTest extends TestCase {
public void testAllocation() throws Throwable {
List threads = new ArrayList();
for (int i = 0; i < 100; i++) {
threads.add(new Requester());
}
MultiThreadedTestRunner mttr = new MultiThreadedTestRunner((TestRunnable[]) threads.toArray(new TestRunnable[threads.size()]));
mttr.runTestRunnables(2 * 60 * 1000);
}
public class Requester extends TestRunnable {
public void runTest() throws Exception {
long startTime = System.currentTimeMillis();
String a = "dummy";
for (int j = 0; j < 1000; j++) {
a += "allocation driven";
}
long endTime = System.currentTimeMillis();
System.out.println(this + ": " + (endTime - startTime) + "ms " + a.length());
}
}
}