• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to speed up Java program?

 
Ranch Hand
Posts: 598
3
jQuery Google App Engine Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
     
    Bobby Sharma
    Ranch Hand
    Posts: 598
    3
    jQuery Google App Engine Windows
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    I thought there is some classes by which we can provide good performance
    and the technic is called profiling if I am not wrong.
     
    Marshal
    Posts: 79177
    377
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    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
    Marshal
    Posts: 79177
    377
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    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
    Posts: 10336
    Hibernate Eclipse IDE Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    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
    Posts: 598
    3
    jQuery Google App Engine Windows
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    OH! I see.
    thanks for ending my curiosity.
     
    Try 100 things. 2 will work out, but you will never know in advance which 2. This tiny ad might be one:
    a bit of art, as a gift, the permaculture playing cards
    https://gardener-gift.com
    reply
      Bookmark Topic Watch Topic
    • New Topic