This sounded like an exercise for the curious, so...
Nothing wrong with exercise or curiosity.
J.java (compiled with javac 1.5.0_06):
public class J {
public static void main(String args[]) {
}
}
jtime.sh:
#!/bin/bash
I=0
while [ $I -lt 100 ]; do
java J
let I=I+1
done
Java real time: 18.12s
Java user time: 8.79s
Java system time: 3.98s
Does this matter in your particular case? No, I certainly don't
think so.
Does it mean that Java has *considerably* more overhead when
starting up than C or a simple shell interpretation? Yes.
If I understand your test correctly and my Unix scripting is iffy at
best you are launching java from the ground up 100 times? There is no
doubt that this will involve more time and overhead than a shell
script or c program as it is an entire JVM getting airborne.
A little more to the point which I was less clear on is if the same
cost extends to a subsequent runtime launched java process? Or is
there some savings in having a java vm already going starting a new
java child process? Something like...
import java.io.*;
public class Launched {
public static void main(String[] args) {
if (args.length == 0) {
long now = System.currentTimeMillis();
System.out.println("test begun at " + now);
for (int i=0;i<100;i++)
rtexec(new String[] { "java","Launched","run" });
System.out.println("test elpased " + (System.currentTimeMillis() -
now) + " millis");
}
else {} /* nop the test runs */
}
Which gets...
test begun at 1149130361763
test elpased 46257 millis
For launching 100 jvms there is some time taken. For launching one
bootstrap child process it would undoubtedly be less. The odds of my
ending up with a bootstrap process + 99 java plugins is somewhat
small. Would the ones I have launch as quickly as what this test
shows? No. So you are also correct this test isn't really
representative. Real or at least interesting fake java processes
would have real or at least interesting fake things for more
realistic measurements.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden
This email sent to email@hidden