• Post Reply Bookmark Topic Watch Topic
  • New Topic

Fine Tuning the Application

 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,

I often see this below word in the performance category .
I'm trying to improve execution time by fine tuning the codes of the application.

Please let me know how this is actually achieved ??
How does this is actually achivied ?? IS it dependent upon any 3rd tools or APIs??
Please help as it gives nice feel to every programmer if his code runs faster

Thanks in advnace .
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is a fairly standard set of tasks you go round:
  • run some performance tests
  • if you discover a problem, profile the application
  • fix any bottlenecks
  • repeat until you are happy with your applciation's performance


  • Profiling the application can be done with any number of third party tools, or you can write your own code to do this, or at its most basic you can make some educated guesses and retest. Eductated guesses are things you should be wary of, and you should never make changes on the back of them without rerunnign your performance tests.
     
    fred rosenberger
    lowercase baba
    Bartender
    Posts: 12342
    39
    Chrome Java Linux
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    "Profiling" refers to using a tool that determines EXACTLY how long each part of your program is taking. It will tell you that THIS method is using 5% of your applications run time, THAT method is using 18%, you're application is waiting for other resources 30% of the time, etc.

    So...once you have this, you can look at what is taking all the time. Perhaps it's your sort algorithm. If you KNOW that is taking most of the time, you can do some analysis to see if there is a better sort algorithm you can use.

    The reason you don't want to guess is that you will almost without a doubt guess wrong. You will ultimately end up spending hours of time improving one little chunk, only to see modest, if any gains. In other words, if you spend a week improving code that was only using 1% of your time, you will not get much more than 1% improvement. However, if you can improve the code that is sucking 50% of the time, you can make huge speed gains.
     
    Ravi Kiran Va
    Ranch Hand
    Posts: 2234
    Eclipse IDE Firefox Browser Redhat
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    really points you specified are interesting , thanks Paul and Fred for your time .

    Paul as you mentioned
    ,

    How one can run performance tests for a Java or J2EE Class ??

    Waiting for your replies , thanks in advance .
     
    steve souza
    Ranch Hand
    Posts: 862
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    << In other words, if you spend a week improving code that was only using 1% of your time, you will not get much more than 1% improvement. However, if you can improve the code that is sucking 50% of the time, you can make huge speed gains. >>
    Well said.

    I find performance problems most often exist in IO (network, file, database). I am often shocked at how fast typical non-IO Java code can run. Even sloppy Java code runs fast. Still old myths persist and developers think about code performance the same way we did 20 years ago. Given Moore's law our (performance doubles every 2 years) often our most effective P&T tool is to sit and wait 2 years. Every year micro-tuning becomes less and less effective, inversely proportional to Moore's law.

    That isn't to say that we shouldn't care about performance, just that microtuning small chunks of Java code often isn't what we should be worried about. Bigger picture things like architecture, IO, and key application algorithms are where we should focus our attention. Even here only after we have profiled. I continuously profile my applications, so I notice when new performance problems pop up. Often it is as I am developing so the code is still fresh in my mind. Having said if I notice what Fred mentions ( that code that takes 1% of overall execution time could be made faster) I try to resist the urge to tune there.

    There are many tools to help. There is no one best tool as they all do different things well. For example JAMon is very good at measuring the IO subsystem. However if you want to measure every single method call there are better options. I think it is important to continue measuring code in production as often real application usage performance is different than in development or test, so a lightweight easy to manage tool that can work in production is always important.
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!