Methods Summary |
---|
public void | chart()
SimpleScheduler ss = new SimpleScheduler(100);
ss.start(); // Ensure Round Robin
configure(); // Ensure Test Length
try {
double sIter = normalize(numIter, doLargeCalculation(1));
System.out.println("\t" + 1 + "\t" + sIter + "\t" + 1.00);
for (int i = 2;; i++) {
double nIter = normalize((numIter * i), doLargeCalculation(i));
System.out.println("\t" + i + "\t" + nIter + "\t" + (nIter/sIter));
}
} catch (Exception e) {
System.out.println("Error: " + e);
}
|
private void | configure()
try {
while(doLargeCalculation(1) < 60)
numIter *= 2;
} catch (Exception e) {
System.out.println("Error: " + e);
}
|
private long | doLargeCalculation(int numThreads)
// Do large useless calculations in the number of threads
// specified and return the number of seconds used.
Vector tv = new Vector();
int priority = Thread.currentThread().getPriority() - 1;
for (int i = 0; i < numThreads; i++) {
Thread th = new Thread(this);
tv.addElement(th);
th.setPriority(priority);
}
long startTime = System.currentTimeMillis();
Enumeration e = tv.elements();
while (e.hasMoreElements()) {
((Thread)e.nextElement()).start();
}
e = tv.elements();
while (e.hasMoreElements()) {
((Thread)e.nextElement()).join();
}
return (System.currentTimeMillis() - startTime) / 1000;
|
public static void | main(java.lang.String[] args)
ScaleChart sc = new ScaleChart();
sc.chart();
|
private double | normalize(int iter, long time)
return ((double)iter * 60.0 / (double)time);
|
public void | run()
float sinValue = 0.0f;
for (int i = 0; i < numIter; i++) {
for (int j = 0; j < 360*100; j++) {
sinValue = (float)Math.sin((j % 360)*Math.PI/180.0);
sinValue *= (float)j / 180.0f;
}
}
|