Hi Hi,
the text below is from the following link;
http://java.sun.com/developer/technicalArticles/Programming/Performance/
"Native methods are really fast.
This sounds silly, but I had heard that the overhead of invoking a native method was so high that it might be the case that small Java methods would be faster. Not! In my test case, I implemented System.arraycopy in plain Java. I then compared this using arrays of different sizes against System.arraycopy . The native (original) method was about an order of magnitude faster, depending on the array size. The native-method overhead may be high, but they're still fast compared to interpreting byte code. If you can use native methods in the JDK, then you can remain 100% pure and have a faster implementation than if you used interpreted methods to accomplish the same thing. "
Ive tested this using some very basic java code, I have only used code like this to do timing;
long startTime = java.lang.System.currentTimeMillis();
so its not real CPU time (I'm on jdk 1.4 and so I don't have access to the new ThreadMXBean interface and features provided for measuring CPU time.
Anyways, I'm seeing that within the debugger there are significant differences (arrayCopy is about 15 times faster). Its under debugger control so this timing doesn't really count. I was encouraged however and went straight to the command line to test outside the debugger.
At the command line, the results show no differences. They both take more or less the same time.
So my questions are;
1) If I measure using real CPU time, can I expect to see greater performance with the System.ArrayCopy approach?
2) I'm compiling under eclipse and I'm not sure if debug versus non-debug mode differences are in place. I can't see where in eclipse I should specify "-g:non" when compiling. I understand eclipse uses its own internal javac compiler. Thus, I'd like to know how to specify a non-debug build (if that makes sense).
thanks for any input.
G
Outside