RE: Performance: switch vs if ... else if

2009-05-22 Thread Peter Crowther
> From: David kerber [mailto:dcker...@verizon.net] > As a > result, right now I don't have any way of generating enough > load to find > a bottleneck in the overall servlet (which is a very good thing!!). That's a win. Congratulations! - Peter ---

Re: Performance: switch vs if ... else if

2009-05-22 Thread David kerber
Caldarale, Charles R wrote: From: Christopher Schultz [mailto:ch...@christopherschultz.net] Subject: Re: Performance: switch vs if ... else if If you find that a tableswitch is /not/ being generated, The tableswitch is being generated for the enum switch (rtFields), but not the char

RE: Performance: switch vs if ... else if

2009-05-22 Thread Caldarale, Charles R
> From: Christopher Schultz [mailto:ch...@christopherschultz.net] > Subject: Re: Performance: switch vs if ... else if > > If you find that a tableswitch is /not/ being generated, The tableswitch is being generated for the enum switch (rtFields), but not the char switch. Howeve

Re: Performance: switch vs if ... else if

2009-05-22 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 David, On 5/21/2009 1:57 PM, David kerber wrote: > Interesting. From that description, depending on how sparse is > "sparse", there's probably a good chance I'm getting a tableswitch. If you find that a tableswitch is /not/ being generated, you coul

RE: Performance: switch vs if ... else if

2009-05-21 Thread Caldarale, Charles R
> From: David kerber [mailto:dcker...@verizon.net] > Subject: Re: Performance: switch vs if ... else if > > Can you point me to a byte code interpreter so I could look at this? The javap tool in the JDK will display the byte codes. (I use it a lot.) If you want, go ahead and send

Re: Performance: switch vs if ... else if

2009-05-21 Thread David kerber
Christopher Schultz wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 David, On 5/19/2009 3:04 PM, David kerber wrote: I have a section of code in a frequently-called (~3.5 million times per day) servlet where I had to process based on a parameter that could take one of 6 different singl

Re: Performance: switch vs if ... else if

2009-05-21 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 David, On 5/19/2009 3:04 PM, David kerber wrote: > I have a section of code in a frequently-called (~3.5 million times > per day) servlet where I had to process based on a parameter that > could take one of 6 different single-character string values.

Re: Performance: switch vs if ... else if

2009-05-20 Thread David kerber
Ronald Klop wrote: As with the tips about usage of char in the switch you can also test using a char in the if ... else. if (myChr.length() != 1) { throw new RuntimeException("invalid length"); } char ch = myChr.charAt(0); if (ch == 'c') { p += 1; } else if (ch == 'r') { p += 2; } ... Shou

Re: Performance: switch vs if ... else if

2009-05-20 Thread Ronald Klop
As with the tips about usage of char in the switch you can also test using a char in the if ... else. if (myChr.length() != 1) { throw new RuntimeException("invalid length"); } char ch = myChr.charAt(0); if (ch == 'c') { p += 1; } else if (ch == 'r') { p += 2; } ... Should make a difference

RE: Performance: switch vs if ... else if

2009-05-19 Thread Caldarale, Charles R
> From: Konstantin Kolinko [mailto:knst.koli...@gmail.com] > Subject: Re: Performance: switch vs if ... else if > > Regarding "Server VM": I accept it as my mistake. I know, that Client > VM is optimized for faster startup (and, well, it is written in the > FAQ [

Re: Performance: switch vs if ... else if

2009-05-19 Thread Konstantin Kolinko
2009/5/20 Caldarale, Charles R : >> From: Konstantin Kolinko [mailto:knst.koli...@gmail.com] >> Subject: Re: Performance: switch vs if ... else if >> >> Server VM precompiles code before using it, while Classic one compiles >> heavily used parts of code on-th

RE: Performance: switch vs if ... else if

2009-05-19 Thread Caldarale, Charles R
> From: Konstantin Kolinko [mailto:knst.koli...@gmail.com] > Subject: Re: Performance: switch vs if ... else if > > Server VM precompiles code before using it, while Classic one compiles > heavily used parts of code on-the-fly. Your terminology is incorrect, as are your descriptio

Re: Performance: switch vs if ... else if

2009-05-19 Thread David kerber
Konstantin Kolinko wrote: ... 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

Re: Performance: switch vs if ... else if

2009-05-19 Thread David kerber
Konstantin Kolinko wrote: 2009/5/19 David kerber : 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

Re: Performance: switch vs if ... else if

2009-05-19 Thread Konstantin Kolinko
2009/5/19 David kerber : > 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 usi

Re: Performance: switch vs if ... else if

2009-05-19 Thread George Sexton
If you're only doing a single character, you would probably get better performance with: switch (sString.char(0)) { case 'A': case 'B': case 'C': } David kerber wrote: Caldarale, Charles R wrote: From: David kerber [mailto:dcker...@verizon.net] Subject: Performance: switch vs if ...

Re: Performance: switch vs if ... else if

2009-05-19 Thread David kerber
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 nu

RE: Performance: switch vs if ... else if

2009-05-19 Thread Caldarale, Charles R
> 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