• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to increase performance

 
Kaushik Baral
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4678
7
Linux Mac OS X VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12143
30
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Pat Farrell
Rancher
Posts: 4678
7
Linux Mac OS X VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@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
Posts: 13064
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic