Java Performance Tuning

Java(TM) - see bottom of page

|home |services |training |newsletter |tuning tips |tool reports |articles |resources |about us |site map |contact us |

Our valued sponsors who help make this site possible
New Relic: Try free w/ production profiling and get a free shirt! 

ManageEngine's Site24x7: End-to-End analysis on Java EE web transactions. Sign up for FREE! 

AppDynamics: Get complete browser to backend visibility. Monitor Now! 

Question of the month: choosing the faster feature

Chart Java Jitter with jHiccup
Monitor and identify pauses in your Java apps. Download now

Why is my application so slow?
Learn 3 ways to detect Java Application Performance Trends

JProfiler
Get rid of your performance problems and memory leaks!


Java Performance Training Courses
COURSES AVAILABLE NOW. We can provide training courses to handle all your Java performance needs

See Your Message Here
You could have your tool advertised here, to be seen by thousands of potential customers

Java Performance Tuning, 2nd ed
The classic and most comprehensive book on tuning Java

Java Performance Tuning Newsletter
Your source of Java performance news. Subscribe now!
Enter email:


New Relic
New Relic: Try free w/ production profiling and get a free shirt!

ManageEngine
ManageEngine's Site24x7: End-to-End analysis on Java EE web transactions. Sign up for FREE!

AppDynamics
AppDynamics: Get complete browser to backend visibility. Monitor Now!


Chart Java Jitter with jHiccup
Monitor and identify pauses in your Java apps. Download now

Why is my application so slow?
Learn 3 ways to detect Java Application Performance Trends

JProfiler
Get rid of your performance problems and memory leaks!


Back to newsletter 039 contents

Which way should I write this piece of code to be faster, using feature X or feature Y?

I get a lot of questions like this. I've even written an article or two explaining the performance difference for some types of features, such as this one on the difference between i++ and ++i or this one on the costs of using exceptions in different ways. These are interesting in a pretty low-level kind of way, and occasionally such information can come in useful.

But I can also understand one of my colleagues' response to that "i++ vs. ++i" article. He basically said "get a life". And for basic performance tuning, I pretty much agree with him. The real response to almost all questions like this is to code according to best practices, making your code as readable and maintainable as possible first of all. If you have a couple of alternative ways to code something, don't start thinking about the alternative performance probabilities. Use the more readable option.

Then profile the code using valid and representative test cases to find where the real bottlenecks are, and fix those bottlenecks to be faster. Sure, occasionally the bottleneck will turn out to be where you were asking about one of those alternative features. But most of those alternative features that you could have asked about will not be located in the real bottlenecks. Which means that your code will be that much more readable in most places. And honestly, everyone will be happier in the long run if your code is more readable. Perl programmers find that out pretty quickly.

So the full answer is: Write beautiful code; then profile that beautiful code and make little bits of it uglier but faster. Don't worry too much about performance while you are writing that beautiful code.

The JavaPerformanceTuning.com team


Back to newsletter 039 contents


Last Updated: 2014-04-01
Copyright © 2000-2014 Fasterj.com. All Rights Reserved.
All trademarks and registered trademarks appearing on JavaPerformanceTuning.com are the property of their respective owners.
Java is a trademark or registered trademark of Oracle Corporation in the United States and other countries. JavaPerformanceTuning.com is not connected to Oracle Corporation and is not sponsored by Oracle Corporation.
URL: http://www.JavaPerformanceTuning.com/news/qotm039.shtml
RSS Feed: http://www.JavaPerformanceTuning.com/newsletters.rss
Trouble with this page? Please contact us