|
|
Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs
Page 2 of 2
java -classpath . com.softtechdesign.math.MathLib
The benchmark code in your main method should execute. If you want to compare the execution speed with the StrictMath versions, change the calls in MathLib.java from MathLib.xxx() to Math.xxx(). On my Pentium 4, 2-GHz machine, the benchmark took 24.5 seconds with the StrictMath routines and 7 seconds with the MathLib (JNI) routines. Not a bad performance boost!
The MathLib (JNI) routines are about half as fast as the Math routines in J2SE 1.3.1—a result of the overhead involved in making a JNI
call. Note that when you make numerous calls to the MathLib routines in a tight loop, you sometimes get an exception:
Unexpected Signal : EXCEPTION_FLT_STACK_CHECK occurred at PC=0x9ED0D2
I submitted a bug report to Sun about this problem, but I have not received a response. The good news is that in practice, I have never gotten the error when running any of my hologram program code.
JNI enables programmers to employ fast C/C++ math routines in their Java programs. It solves problems for which Java is poorly suited: when you need the speed of C or assembler, or when you need to write low-level code to communicate directly with hardware. It can also be used to access legacy applications or interface with libraries written in other languages.
This MathLib example barely scratches the surface of what you can do with JNI. JNI native methods can create and manipulate Java objects
such as strings and arrays and accept Java objects as parameters. JNI can even catch and throw exceptions from native methods
and handle these exceptions from the native code or from your Java application. This almost seamless sharing of objects makes
it very easy to incorporate native methods in your Java applications.
Archived Discussions (Read only)