Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #9092

Re: Getter performance

From Wanja Gayk <brixomatic@yahoo.com>
Newsgroups comp.lang.java.programmer
Subject Re: Getter performance
Date 2011-10-22 21:11 +0200
Organization Netfront http://www.netfront.net/
Message-ID <MPG.290d33a65d9aef3e9896c7@202.177.16.121> (permalink)
References <4e99f537$0$623$426a74cc@news.free.fr>

Show all headers | View raw


In article <4e99f537$0$623$426a74cc@news.free.fr>, aeris@imirhil.fr 
says...

> How can we explain this not obvious huge difference ( 50 and 95% ) ?

Basically you don't want to test things like "getter" vs "field access", 
but if you do, then don't test it with a microbenchmark, but set up a 
real world test on your application with realistic data and typical 
runtime, measure carefully, think about the lack of timer-precision 
(System.currentTimeMillis() has a variance of almost 10 ms on some 
operating systems), JIT-compiler-overhead, operating system caching, 
synamic compiler optimizations and stuff like that. Testing such things 
is very hard, way harder than you might initially think!

This should get you an idea:
http://www.ibm.com/developerworks/java/library/j-jtp02225/index.html

When performance is important, get a profiler, such as "yourkit" or 
"jprofiler" and measure instead of guessing. Use that tool to measure 
your current application not some flawed microbenchmark.
If you have successfully pinpointed the real performence bottlenecks in 
your application, always start with the most serious ones.
First think about possibilities to _avoid_ them, such as changing the 
algorithm. Oh yeah, and if you think about eliminating object creation 
overhead, please mind that pooling and re-using objects may actually 
cost you more than it saves you when it comes to garbage collection. 
Most objects are cheap to create and objects that die young are easy to 
collect. If you make them live too long, they can make it into the "old 
generation" only  to get collected by an algorithm that is tuned for 
cleaning out memory that has only few dead objects in it and doesn't 
like too many objects that are doomed to die soon.

Last but not least, very important: Only optimize if there's a real need 
for optimization. As soon as your application meets the performance goal 
("best possible" is not a sane goal) you're fine. Don't waste cash on 
saving the user half a tenth of a second for getting the result of his 
button click. That would be just stupid.
If you can replace a thousand dollars worth of programming effort by 
sticking a few dollars more memory into your server, forget about tuning 
your application, buy the RAM, it's cheaper.

Kind regards,
Wanja

-- 
..Alesi's problem was that the back of the car was jumping up and down 
dangerously - and I can assure you from having been teammate to 
Jean Alesi and knowing what kind of cars that he can pull up with, 
when Jean Alesi says that a car is dangerous - it is. [Jonathan Palmer]

--- Posted via news://freenews.netfront.net/ - Complaints to news@netfront.net ---

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Find similar


Thread

Getter performance Aéris <aeris@imirhil.fr> - 2011-10-15 23:03 +0200
  Re: Getter performance Arne Vajhøj <arne@vajhoej.dk> - 2011-10-15 17:36 -0400
    Re: Getter performance Arne Vajhøj <arne@vajhoej.dk> - 2011-10-15 17:42 -0400
      Re: Getter performance BGB <cr88192@hotmail.com> - 2011-10-15 15:00 -0700
        Re: Getter performance markspace <-@.> - 2011-10-15 15:20 -0700
          Re: Getter performance David Lamb <dalamb@cs.queensu.ca> - 2011-10-20 12:45 -0400
            Re: Getter performance Roedy Green <see_website@mindprod.com.invalid> - 2011-10-21 14:27 -0700
              Re: Getter performance Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2011-10-21 18:57 -0700
                Re: Getter performance Patricia Shanahan <pats@acm.org> - 2011-10-22 07:27 +0100
                Re: Getter performance Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-10-22 09:57 -0300
              Re: Getter performance Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-10-21 22:12 -0400
    Re: Getter performance Aéris <aeris@imirhil.fr> - 2011-10-15 23:59 +0200
      Re: Getter performance Arne Vajhøj <arne@vajhoej.dk> - 2011-10-15 19:44 -0400
        Re: Getter performance Aéris <aeris@imirhil.fr> - 2011-10-16 13:14 +0200
          Re: Getter performance Lars Enderin <lars.enderin@telia.com> - 2011-10-16 16:28 +0200
  Re: Getter performance Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-10-16 09:47 -0400
  Re: Getter performance Jaap Droogers <JaapDroogers@unusable.meel.homelinux.net> - 2011-10-16 22:12 +0200
    Re: Getter performance BGB <cr88192@hotmail.com> - 2011-10-16 13:58 -0700
    Re: Getter performance David Lamb <dalamb@cs.queensu.ca> - 2011-10-20 12:51 -0400
      Re: Getter performance Paul Cager <paul.cager@googlemail.com> - 2011-10-21 08:49 -0700
  Re: Getter performance Roedy Green <see_website@mindprod.com.invalid> - 2011-10-21 08:02 -0700
  Re: Getter performance Wanja Gayk <brixomatic@yahoo.com> - 2011-10-22 21:11 +0200

csiph-web