• Post Reply Bookmark Topic Watch Topic
  • New Topic

how i can improve the speed of my java program  RSS feed

 
Kendly paul
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello every body i am Kendly paul, student in programing language (java) in 3rd year, as you can notice i am new to java. To get started i developed an IDE for java in order to teach the beginners java. i want some advice how i can make that better like the recents IDE
 
Campbell Ritchie
Marshal
Posts: 56584
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

It's hard to say in general how to improve the speed of your Java program.

Programs in any programming language (not just Java) will be slow if you choose the wrong algorithms or data structures, for example an inappropriate sorting algorithm, or choosing a LinkedList when you are doing many lookups by index in the list (an ArrayList would be more appropriate in that case).

If you want to improve the performance of your program, the first thing to do is measure - use tools, such as a profiler, to find out exactly which part of the program is slow, and then concentrate on improving the relevant parts.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12565
49
Chrome Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The general advice given is "don't".

Unless you have documented requirements, you are on a never-ending quest. You'll always be saying "how can I make it faster?" with no way to ever quit.

Having said that, Jesper's advice is 100% correct - if you are going the software route. Profile it. Find exactly WHERE your code is spending time, and improve that (if possible).

There are also hardware factors. Disk I/O can often be a choke point, so perhaps buying a faster drive. What about a faster CPU? sometimes more memory can help. You may want to investigate those as well.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree with Fred
The general advice given is "don't".


Over my nearly 20 year involvement with Java I have seen oh-so-many "tips" for speed - most of them producing ugly code for little or no gain.

The very best thing you can do is to choose the correct algorithm for the problem.

Furthermore, strive for clarity so when you get back to the code later you can remember what you were doing.

Bill
 
fred rosenberger
lowercase baba
Bartender
Posts: 12565
49
Chrome Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To expand further...You may spend days/weeks working on fine tuning your application. In the end, you shave a few milliseconds off the time it takes. Most users would never notice. Further, if it is some kind of GUI, much of the time the program is idling, waiting for user input. Does it really make sense to save a few milliseconds if the users take 5 or 10 or more seconds to input something to let the program proceed? Or would your time be better spent adding new features?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!