optimising : Java Glossary

go to home page O words local find full screen, hide local find menu Google search web for more information on this topic jump to foot of page translate this page with Babelfish punctuation 0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z (all) ©1996-2009 Roedy Green, Canadian Mind Products
optimising
Optimising, sometimes called tuning or fine tuning is the art of making computer programs run faster. It is also the art of finding the optimum tradeoffs between ease of maintenance, simplicity, terseness, speed, portability, low RAM usage and quickness to get the app working in the first place. Don’t go crazy with optimisation. If you spend an extra man-week on a project optimising, over the lifetime of the project, you had better save at least a man-week of other people’s time waiting for the program, and you must consider that you have deprived those same people of using your program a week earlier.
We should forget about small inefficiencies, say about 97% of the time: premature optimization is the root of all evil.
~ Donald Ervin Knuth (born: 1938-01-10 age: 71)
A fast program is not as important as a correct one.
~ Steve McConnell
The only result of optimization you can usually be sure of without measuring performance is that you’ve made your code harder to read.
~ Steve McConnell
Jackson’s rules of Optimization:
  1. Don’t do it.
  2. (For experts only) Don’t do it yet — that is until you have a perfectly clear and unoptimized solution.
~ M.A. Jackson

How to Proceed

If you have a program that is running too slowly, here is what to do. I suggest following the steps in this order:
  1. Get someone experienced in these matters to look over your code and find out where it is spending all its time. It helps to have a fresh pair of eyes on the problem. They will use a profiler to determine this. This identifies the bottlenecks.
  2. Look at the bottleneck code for obvious blunders and correct them.
  3. See if there is a totally different faster algorithm for accomplishing the same thing, e.g. hashMap vs linear searching a long table.
  4. Clean up the bottleneck code to ship shape. This is not considered optimising, just getting it squeaky clean with no rambling.
  5. See if the program is recomputing anything. Perhaps it can avoid redoing work it has already done. The form of optimisation tends to make the code more complex and less maintainable, but not always. Sometimes inexperienced programmers call methods where they are not needed at all, and that code can be yanked out entirely.
  6. Consider the use of a native optimising compiler such as JET.
  7. If all else fails try JNI with C/ C++. Beware. JNI only saves you CPU time if you can do a substantial amount of work in C/C++ on each call to offset the high overhead of the call.
  8. If even that fails try JNI with assembler.
  9. If that fails, tell your customers they will need bigger iron.

What Not To Do

General Tips

The sorts of thing you can legitimately do are:

A Touch of Cynicism

In the end, what counts in the marketplace is the psychological impression a program gives to its users.

You can “speed up” a program by wasting even more cycles with progress bars and animated spinners — the approach pioneered by Microsoft.

If the program behaves what appears to behave like a reluctant or lazy human, it will be perceived as slow. If a program appears industrious, it can actually be a pig and get away with it.

In GUIs, what most often counts most is some sort of rapid acknowledgement feedback not the total elapsed time of some process.

Books

book cover recommend book⇒Code Complete : A Practical Handbook of Software Construction
 paperback
ISBN13:978-1-55615-484-3impressioncounter
publisher:Microsoft Press
published:1993-05-14
by:Steve McConnell
Gives lots of practical advice on optimising. He talks mostly about C with examples in Fortran, Pascal, Basic and Ada. He doesn’t talk about Java. It didn’t exist when the book was written.
UK flag abe books.co.uk abe books.ca Canadian flag
UK flag amazon.co.uk. amazon.ca. Canadian flag
German flag abe books.de chapters.indigo.ca. Canadian flag
German flag amazon.de. abe books.com American flag
French flag abe books.fr amazon.com. American flag
French flag amazon.fr. barnes and noble.com American flag
Italian flag abe books.it powells.com American flag
Spanish flag iberlibro.com sony e-books American flag
Australian flag abe books anz

book cover recommend book⇒Java Performance Tuning, 2nd edition
 paperback
ISBN13:978-0-596-00377-7impressioncounter
publisher:O’Reilly recommended
published:2003-01
by:Jack Shirazi
Recommended. O’Reilly Safari book available to read online for a fee. Includes tuning EE, JDBC, servlets and JSPs, and EJBs. Read more about it. Make sure you get the second edition (or later).
UK flag abe books.co.uk abe books.ca Canadian flag
UK flag amazon.co.uk. amazon.ca. Canadian flag
German flag abe books.de chapters.indigo.ca. Canadian flag
German flag amazon.de. abe books.com American flag
French flag abe books.fr amazon.com. American flag
French flag amazon.fr. barnes and noble.com American flag
Italian flag abe books.it powells.com American flag
Spanish flag iberlibro.com sony e-books American flag
Australian flag abe books anz download o’reilly safari American flag

book cover recommend book⇒Java Platform Performance: Strategies and Tactics
 paperback
ISBN13:978-0-201-70969-8impressioncounter
publisher:Prentice Hall
published:2000-06-10
by:Steve Wilson, Jeff Kesselman
UK flag abe books.co.uk abe books.ca Canadian flag
UK flag amazon.co.uk. amazon.ca. Canadian flag
German flag abe books.de chapters.indigo.ca. Canadian flag
German flag amazon.de. abe books.com American flag
French flag abe books.fr amazon.com. American flag
French flag amazon.fr. barnes and noble.com American flag
Italian flag abe books.it powells.com American flag
Spanish flag iberlibro.com sony e-books American flag
Australian flag abe books anz

book cover recommend book⇒Enterprise Java Performance
 paperback
ISBN13:978-0-13-017296-9impressioncounter
publisher:Prentice Hall
published:2000-08
by:Steven L. Halter, Steven J. Munroe
UK flag abe books.co.uk abe books.ca Canadian flag
UK flag amazon.co.uk. amazon.ca. Canadian flag
German flag abe books.de chapters.indigo.ca. Canadian flag
German flag amazon.de. abe books.com American flag
French flag abe books.fr amazon.com. American flag
French flag amazon.fr. barnes and noble.com American flag
Italian flag abe books.it powells.com American flag
Spanish flag iberlibro.com sony e-books American flag
Australian flag abe books anz

book cover recommend book⇒Sun Performance and Tuning: Java and the Internet (2nd Edition)
 paperback
ISBN13:978-0-13-095249-3impressioncounter
publisher:Prentice Hall
published:1998-04-17
by:Adrian Cockcroft, Richard Pettit, Sun Microsystems
UK flag abe books.co.uk abe books.ca Canadian flag
UK flag amazon.co.uk. amazon.ca. Canadian flag
German flag abe books.de chapters.indigo.ca. Canadian flag
German flag amazon.de. abe books.com American flag
French flag abe books.fr amazon.com. American flag
French flag amazon.fr. barnes and noble.com American flag
Italian flag abe books.it powells.com American flag
Spanish flag iberlibro.com sony e-books American flag
Australian flag abe books anz

book cover recommend book⇒Java ™ Puzzlers : Traps, Pitfalls, and Corner Cases
 paperback
ISBN13:978-0-321-33678-1impressioncounter
publisher:Addison-Wesley
published:2005-07-04
by:Joshua Bloch, Neal Gafter
A set of 95 short programs that give astonishing results. When you understand them, you understand the quirkier features of Java. Bloch wrote much of the JDK class library. He also wrote the Effective Java Programming Language Guide
UK flag abe books.co.uk abe books.ca Canadian flag
UK flag amazon.co.uk. amazon.ca. Canadian flag
German flag abe books.de chapters.indigo.ca. Canadian flag
German flag amazon.de. abe books.com American flag
French flag abe books.fr amazon.com. American flag
French flag amazon.fr. barnes and noble.com American flag
Italian flag abe books.it powells.com American flag
Spanish flag iberlibro.com sony e-books American flag
Australian flag abe books anz

book cover recommend book⇒Effective Java: Second Edition
 paperbackkindle
ISBN13:978-0-321-35668-0impressioncounterB000WJOUPAclickcounter
publisher:Prentice Hall
published:2008-05-28
by:Joshua Bloch
No design patterns, just generic advice on good Java programming style.
UK flag abe books.co.uk abe books.ca Canadian flag
UK flag amazon.co.uk. amazon.ca. Canadian flag
German flag abe books.de chapters.indigo.ca. Canadian flag
German flag amazon.de. abe books.com American flag
French flag abe books.fr amazon.com. American flag
French flag amazon.fr. barnes and noble.com American flag
Italian flag abe books.it powells.com American flag
Spanish flag iberlibro.com sony e-books American flag
Australian flag abe books anz


CMP homejump to top You can get the freshest copy of this page from: or possibly from your local J: drive (Java virtual drive/mindprod.com website mirror)
http://mindprod.com/jgloss/optimising.html J:\mindprod\jgloss\optimising.html
CMP logofeedback Please email your feedback for publication, errors, omissions, typos, formatting errors, ambiguities, unclear wording, broken/redirected link reports, suggestions to improve this page or comments to Roedy Green : feedback email
mindprod.com IP:[65.110.21.43]
view BlogYour face IP:[38.107.191.105]
You are visitor number 10,404.