Q
Qu0ll
I am converting a JFrame based application to a JApplet based applet but I
found that by only making the necessary changes and retaining as much code
as possible the applet seems to perform quite a bit slower than the app.
So I whipped up this very basic test class and ran it from within the app
and the applet. It turns out that after 20 tests the app performs on
average almost exactly 25% faster than the applet. I am using JSE 6 Update
10 b17 and the browser is Firefox 3.
Note, there is no graphics manipulation or display so why should the code
perform so much slower in the applet?
public class PerformanceTester {
static final int I = 25000;
static final int N = 10000;
double[] d1;
double[] d2;
double[] d3;
double total;
double n;
public void run() {
final long start = System.currentTimeMillis();
for (int i = 0; i < PerformanceTester.I; i++) {
this.d1 = new double[PerformanceTester.N];
this.d2 = new double[PerformanceTester.N];
this.d3 = new double[PerformanceTester.N];
for (int j = 0; j < PerformanceTester.N; j++) {
this.d1[j] = Math.random() * 1000.0;
this.d2[j] = Math.random() * 1000.0;
}
for (int j = 0; j < PerformanceTester.N; j++) {
this.d3[j] =
this.d1[(int)(Math.random() * PerformanceTester.N)]
* this.d2[(int)(Math.random() * PerformanceTester.N)];
}
for (int j = 0; j < PerformanceTester.N; j++) {
++this.n;
this.total += this.d3[j];
}
}
final long end = System.currentTimeMillis();
System.out.println("Average = " + this.total / this.n + ", Time = "
+ (end - start) / 1000.0);
}
}
--
And loving it,
-Qu0ll (Rare, not extinct)
_________________________________________________
(e-mail address removed)
[Replace the "SixFour" with numbers to email me]
found that by only making the necessary changes and retaining as much code
as possible the applet seems to perform quite a bit slower than the app.
So I whipped up this very basic test class and ran it from within the app
and the applet. It turns out that after 20 tests the app performs on
average almost exactly 25% faster than the applet. I am using JSE 6 Update
10 b17 and the browser is Firefox 3.
Note, there is no graphics manipulation or display so why should the code
perform so much slower in the applet?
public class PerformanceTester {
static final int I = 25000;
static final int N = 10000;
double[] d1;
double[] d2;
double[] d3;
double total;
double n;
public void run() {
final long start = System.currentTimeMillis();
for (int i = 0; i < PerformanceTester.I; i++) {
this.d1 = new double[PerformanceTester.N];
this.d2 = new double[PerformanceTester.N];
this.d3 = new double[PerformanceTester.N];
for (int j = 0; j < PerformanceTester.N; j++) {
this.d1[j] = Math.random() * 1000.0;
this.d2[j] = Math.random() * 1000.0;
}
for (int j = 0; j < PerformanceTester.N; j++) {
this.d3[j] =
this.d1[(int)(Math.random() * PerformanceTester.N)]
* this.d2[(int)(Math.random() * PerformanceTester.N)];
}
for (int j = 0; j < PerformanceTester.N; j++) {
++this.n;
this.total += this.d3[j];
}
}
final long end = System.currentTimeMillis();
System.out.println("Average = " + this.total / this.n + ", Time = "
+ (end - start) / 1000.0);
}
}
--
And loving it,
-Qu0ll (Rare, not extinct)
_________________________________________________
(e-mail address removed)
[Replace the "SixFour" with numbers to email me]