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 on-the-fly.

2. This line:
rtFields.valueOf( myChr )
does all the job that your if/elif/else tree did. That is, I expect
that all the time
is spent in there, not in switch(number) that follows it.

3. You can try the following:

    private static void switchSub2( String myChr ) {
      if (myChr.length() != 1) {
          throw new AssertionError();
      }
      switch ( myChr.charAt(0)) {
      case 'c':
          o += 1;
          break;
      case 'r':
          o += 2;
          break;
      case 'l':
          o += 3;
          break;
      case 'a':
          o += 4;
          break;
      case 't':
          o += 5;
          break;
      case 'd':
          o += 6;
          break;
      }
      return;
  }
You're right; it's dramatically faster, ~2.5x!!

Thanks!
D



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

Reply via email to