Performance Checklist
Many of these suggestions apply only after a bottleneck has been identified:
Test your benchmarks on each version of Java available to you (classes, compiler, and VM) to identify any performance improvements.
Test performance using the target VM or “best practice” VMs.
Include some tests of the garbage collector appropriate to your application, so that you can identify changes that minimize the cost of garbage collection in your application.
Run your application with both the
-verbosegcoption and with full application tracing turned on to see when the garbage collector kicks in and what it is doing.Vary the
-Xmx/-Xmsoption values to determine the optimal memory sizes for your application.Avoid using the VM options that are detrimental to performance.
Replace generic classes with more specific implementations dedicated to the data type being manipulated, e.g., implement a
LongVectorto holdlongs rather than use aVectorobject withLongwrappers.Extend collection classes to access internal arrays for queries on the class.
Replace collection objects with arrays where the collection object is a bottleneck.
Try various compilers. Look for compilers targeted at optimizing performance: these provide the cheapest significant speedup general to all runtime environments.
Use the
-Ooption (but always check that it does not produce slower code).Identify the optimizations a compiler is capable of so that you do not negate the optimizations.
Use a decompiler to determine ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access