Performance Checklist
Most of these suggestions apply only after a bottleneck has been identified:
Ensure that performance tests are run with the same amount of I/O as the expected finished application. Specifically, turn off any extra logging, tracing, and debugging I/O.
Use
Runtime.traceMethodCalls(), when supported, to count I/O calls.Redefine the I/O classes to count I/O calls if necessary.
Include logging statements next to all basic I/O calls in the application.
Parallelize I/O by splitting data into multiple files.
Execute I/O in a background thread.
Avoid the filesystem file-growing overhead by preallocating files.
Try to minimize the number of I/O calls.
Buffer to reduce the number of I/O operations by increasing the amount of data transfer each I/O operation executes.
Cache to replace repeated I/O operations with much faster memory or local disk access.
Avoid or reduce I/O calls in loops.
Replace
System.outandSystem.errwith customizedPrintStreamclasses to control console output.Use logger objects for tight control in specifying logging destinations.
Try to eliminate duplicate and unproductive I/O statements.
Keep files open and navigate around them rather than repeatedly opening and closing the files.
Consider optimizing the Java
byte-to-char(andchar-to-byte) conversion.Handle serializing explicitly, rather than using default serialization mechanisms.
Use transient fields to avoid serialization.
Use the
java.io.Externalizableinterface if overriding the default serialization ...
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