Konstantin Kolinko wrote:
2009/5/19 David kerber <dcker...@verizon.net>:
Caldarale, Charles R wrote:
From: David kerber [mailto:dcker...@verizon.net]
Subject: Performance: switch vs if ... else if

I had to process based on a parameter that could take
one of 6 different single-character string values.  I
had been using an if .. else if construct.

Interesting numbers.  Can you show us the exact code of the if .. else
construct?

 - Chuck

Here is the entire code.  The variables o and p are used to make sure there
is actually some work done in each call to the test methods.  I've seen
cases (mainly in Delphi) where an optimizer completely removed large chunks
of code because it wasn't doing anything.  I don't know of java can do that
or not...

public class SwitchVsIfTest {
  (...)


1. If you are doing tests with the classic VM, allow it some time to warmup and
compile your code. That is, run the same test first with a smaller count of
iterations.

Server VM precompiles code before using it, while Classic one compiles
heavily used parts of code on-the-fly.
That's part of the reason I ran the tests twice in a row, in the main() method (that, and cache warming).

D



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to