aspose file tools*
The moose likes Performance and the fly likes How to increase performance Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Performance
Bookmark "How to increase performance" Watch "How to increase performance" New topic
Author

How to increase performance

Kaushik Baral
Greenhorn

Joined: Aug 08, 2009
Posts: 23
Hi,

can any one give me some simple tips to increase the performance of the java code? in my project there i have used "System.out.println()" a lot. will it increase the performance if i delete these ? if anyone know any good book for java performance tuning then please let me know.

thanks a lot.
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4659
    
    5

Yes, deleting them (or any log calls) will improve performance.

The rules for increasing performance are simple and immutable:

1) instrument code
2) find where it is actually spending time when you execute the code
3) remove the biggest bottle neck
4) if you have improved it enough, go out for dinner and beer.
5) if not, go to step 2.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11480
    
  16

Pat Farrell wrote:
The rules for increasing performance are simple and immutable:

0) determine actual metrics on what performance needs to be
1) instrument code in clear, readable, easy to follow manner
1a) if code meets documented performance metrics, go to step 5...
2) find where it is actually spending time when you execute the code
3) remove the biggest bottle neck
4) if you have not improved it enough, go to step 2
5) go out for a beer

fixed that for ya...

Pat and i are basically saying:
1) Don't worry about performance unless you have a DOCUMENTED NEED.
2) use some tool to determine where things REALLY slow down, since if you guess, you will be wrong.
3) Trying to write code that is 'fast', at the expense of 'readable' or 'understandable' is a loosing battle. You will inevitably spend more time fixing/debugging poorly written code than users will ever save by writing it that way.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4659
    
    5

@fred's right.

I can always make code be twice as fast, or run in half the time. Always.
And I can always do it again. And again.

But it gets harder and starts to cost serious amounts of engineering effort, hardware, etc.

Decide *before* you start when you will stop.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12825
    
    5
I like this site and newsletter by a well known java programmer.

For a fun time do a google search for "premature optimization is the root of all evil" - or look at this wikipedia page.

Bill
Kaushik Baral
Greenhorn

Joined: Aug 08, 2009
Posts: 23
Thanks to all of you for your valuable time and helpful suggestions. i can delete the unnecessary "sysouts" and go for beer at least.
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
You first need to explicitly define what "performance" means to your application. Speed of transactions, number of concurrent users, speed of web page generation, speed of database queries, etc.

Once you have defined what exactly needs possible performance improvements, then you need to measure what you currently have.

With your documented Performance requirements and your documented baseline measurements, you will be ready to start to think about how you can improve performance.

Keep in mind that many micro-level mille-second speed improvements are typically not worth the trouble or hassle. And in many cases, make code more confusing. It is usually better to
strive for a greater level of understandability than shaving a couple of seconds off of a process.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: How to increase performance