We have some machines running Debian 2.1 here (libc 5.4.46), and we are
running the pre-v2 Linux port of Java.
There are strange timings for the following programs. In particular, the
static version runs at about half the speed of the nonstatic version,
which seems backwards; static takes 232s and nonstatic takes 123s.
Normally, the static call should be faster to execute, since there is less
work to do. Does anyone have any ideas about why this is the case?
pat
// virtual invokes.
class myprog {
public static void main(String[] args) {
int i,j,n;
System.out.println("Beginning");
long begTime = System.currentTimeMillis();
System.out.println(begTime);
Bidule bid = new Bidule();
for (n=1; n<50000000; n++) {
bid.change(1);
bid.change(2);
bid.change(3);
bid.change(4);
bid.change(5);
bid.change(6);
}
System.out.println("End");
long endTime = System.currentTimeMillis();
System.out.println(endTime);
System.out.println(" lasting : " + (endTime-begTime) );
}
}
class Bidule{
int i;
public Bidule() {
i=0;
}
public void change(int new_i) {
//System.out.println("former i : "+i+" new i : "+new_i);
i=new_i;
}
}
// myprog_static
class myprog_static {
public static void main(String[] args) {
int i,j,n;
System.out.println("Beginning");
long begTime = System.currentTimeMillis();
System.out.println(begTime);
Bidule_static bid = new Bidule_static();
for (n=1; n<50000000; n++) {
Bidule_static.change(bid, 1);
Bidule_static.change(bid, 2);
Bidule_static.change(bid, 3);
Bidule_static.change(bid, 4);
Bidule_static.change(bid, 5);
Bidule_static.change(bid, 6);
}
System.out.println("End");
long endTime = System.currentTimeMillis();
System.out.println(endTime + " lasting "+ (endTime-begTime));
}
}
class Bidule_static{
int i;
public Bidule_static() {
i=0;
}
public static void change( Bidule_static bidule, int new_i) {
bidule.i=new_i;
}
}
----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]