Win a copy of Spark in Action this week in the Open Source Projects forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

how to speed up Java program?

 
Ranch Hand
Posts: 598
3
jQuery Google App Engine Windows
  • Mark post as helpful
  • send pies
  • 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
  • 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
    • 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: 69738
    277
    • Mark post as helpful
    • send pies
    • 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: 69738
    277
    • Mark post as helpful
    • send pies
    • 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
    • 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
    • Quote
    • Report post to moderator
    OH! I see.
    thanks for ending my curiosity.
     
    No prison can hold Chairface Chippendale. And on a totally different topic ... my stuff:
    Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
      Bookmark Topic Watch Topic
    • New Topic