Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Regarding Performance

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Thanks tiny ad, for helping me escape the terrible comfort of this chair.
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic