tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David kerber <dcker...@verizon.net>
Subject Re: Performance: switch vs if ... else if
Date Tue, 19 May 2009 20:31:43 GMT
Konstantin Kolinko wrote:
> 2009/5/19 David kerber <dckerber@verizon.net>:
>   
>> Caldarale, Charles R wrote:
>>     
>>>> From: David kerber [mailto:dckerber@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-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message