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

how to speed up Java program?

Bobby Sharma
Ranch Hand

Joined: Mar 18, 2008
Posts: 574
    
    1

I know there is way by which we can speed up our Java programs.
what's that I don't know.
please give some lights.

best regards,
omi


Back to Java , again.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

That depends on:
  • what your Java program does
  • how it does it
  • what environment it runs in
  • how that environment is optimised

  • and so on.

    I'll move this over to the Performance forum. If you can flesh out some of the above perhaps someone can help.

    Of course, the single most important question you need to ask before spending more than a cursory amount of time on optimising performance is "do I have a performance problem?". If you don't, don't bother.


    JavaRanch FAQ HowToAskQuestionsOnJavaRanch
    Bobby Sharma
    Ranch Hand

    Joined: Mar 18, 2008
    Posts: 574
        
        1

    I thought there is some classes by which we can provide good performance
    and the technic is called profiling if I am not wrong.
    Campbell Ritchie
    Sheriff

    Joined: Oct 13, 2005
    Posts: 39834
        
      28
    The simplest answer is that you oughtn't to do anything. Read a couple of articles by Brian Goetz I found: this one, and this one.

    The one thing you can do is to check for inefficient algorithms, eg
  • Using + or += in multiple lines for String concatenation.
  • Using O(n^2) sorting algorithms rather than O(n log n).
  • In general, as Goetz tells us, it is better to write simple code and leave the optimisation to the compiler, and not to try lots of micro-management. This applies to other languages too, see for example Miller and Quilici the Joy of C where they have some figures about C optimisation.
    Campbell Ritchie
    Sheriff

    Joined: Oct 13, 2005
    Posts: 39834
        
      28
    Originally posted by omi sharma:
    I thought there is some classes by which we can provide good performance
    and the technic is called profiling if I am not wrong.
    Yes, profiling is available, but I know nothing about it.

    If you go through the classes in the collections framework, eg ArrayList, LinkedList, they tell you the complexity they run in. Read the API documentation for those two classes and see where they would provide the better performance.
    Paul Sturrock
    Bartender

    Joined: Apr 14, 2004
    Posts: 10336

    Profiling can show you where performance hotspots are, it doesn't do anything to improve the performance of the application. That only happens when you manually respond to what the profiler tells you.
    Bobby Sharma
    Ranch Hand

    Joined: Mar 18, 2008
    Posts: 574
        
        1

    OH! I see.
    thanks for ending my curiosity.
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: how to speed up Java program?