• Post Reply Bookmark Topic Watch Topic
  • New Topic

Regarding Performance  RSS feed

 
Ram Krish
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

What are the basic performance tips that are to be followed while coding a java program ? (bare minimum)...

Thanks in advance.

Ram
SCJP 1.4
 
Joe Ess
Bartender
Posts: 9406
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ram Krish:
(bare minimum)...


Don't write slow code.
There's much more to performance than a couple of tips. Software is vastly too complex for that. This is why we have the First Rule of Optimization. By trying to optimize your code before you have established where a bottleneck is you are probably:
1. Focusing on non-critical parts of code (for example, writing a custom XML parser when the time it takes to parse a file is trivial compared to the amount of time it takes to read the file from a network drive)
2. Introducing bugs and maintaince headaches (Java already has numerous XML parsers which have been tested and debugged. Why reinvent the wheel?)
3. Wasting time and effort on "optimized" code when optimization isn't necessary (this XML parser gets run once a month by a cron job. who cares how fast it is? using your time efficiently is an optimization as well)
Now this does not excuse you from knowing how to use the Java language effectively. Check out the online book Java Platform Performance Strategies. Not only does cover effective use of Java but it also covers how to measure performance and use benchmarks to compare solutions.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There really are only two basic tips:

- Optimize for maintainability instead of performance per default.

- Once you get a real performance problem, use a profiler to find the bottleneck. *Then* come to the this forum to get tips on how to resolve your specific problem.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!