|
|
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 5 of 7
The performance gains from dead code elimination can be significant, but the overhead of the optimization calculation would most likely be prohibitive in a JIT compiler. It should be noted, however, that dead code is a result of sloppy programming. Competent programmers should be sensitive to the necessity of eliminating any dead code without having to rely upon the compiler to do it for them.
The common optimizations that compilers perform may be divided into groups based on performance gains and computational expense:
Tertiary optimizations can add an additional 5 percent performance gain, but at much greater expense.
This discussion has only listed two of the simpler optimizations that a compiler can perform. For a complete discussion of compilers and optimization theory, see "Compilers. Principles, Techniques, and Tools" and "Crafting a Compiler" (in the Resources section at the end of the article).
The table below shows several examples of runtime for a Java routine versus the same functions in C++. Without a JIT, Java performs three or four times worse than C++.
As predicted by the theoretical evaluation, Java with a JIT performs precisely like C++. The only exception is the performance of the Run-time type identification (RTTI) under C++.
Complex object-oriented programs contain complex hierarchies. These hierarchies often require that one program cast for a parent class to a child class. This type of cast is called a down cast.
Run-time type identification identifies when a parent class is cast into an invalid child class. Without RTTI, complex systems often experience subtle bugs that are difficult to detect and can compromise the entire project.
Most C++ programmers turn off RTTI due to its expense. Java does not allow programmers to turn off RTTI since this would violate the Java security model. In these tests, it is evident that in C++, RTTI is very expensive as compared to Java.
| Test | Description | Time (secs) C++ |
Time (secs) Java (JIT) |
Time (secs) Java (Bytecode interpreter) |
|---|
| Integer division | This test loops 10 million times on an integer division. | 1.8 | 1.8 | 4.8 |
| Dead code | This test loops 10 million times and performs an operation that is never used. | 3.7 | 3.7 | 9.5 |
| Dead code with Integer division | This test loops 10 million times and performs an operation that is never used and one that is. | 5.4 | 5.7 | 20 |
| Floating-point division | This test loops 10 million times on a floating-point division. | 1.6 | 1.6 | 8.7 |
| Static method | This test loops 10 million times calling a static method which contains an Integer division. | 1.8 | 1.8 | 6.0 |
| Member method | This test loops 10 million times calling a member method which contains an Integer division. | 1.8 | 1.8 | 10 |
| Virtual member method | The Member method test performed above is not really valid. In Java all Member methods are virtual. This test loops 10 million times calling a Virtual member method which contains an Integer division. | 1.8 | 1.8 | 10 |
| Virtual member method with down cast and Run-Time Type Identification (RTTI) | This test loops 10 million times calling a Virtual method on a class that has been down cast using RTTI. | 11 | 4.3 | 12 |
| Virtual member method with invalid down cast and Run-Time Type Identification (RTTI) | This test loops 10 million times calling a Virtual method on a class that has been down cast using RTTI. | Crash | Crash | Crash |
Programs must allocate memory to store information and perform calculations. When the program is through using the memory, it must release it back to the system so that it will be available to other parts of the system.