Scott G. Miller wrote:

>
>My only comment is that the code in TwofishAlgorithm was designed to be
>inlined by the JVM at Runtime, so yes, it should improve startup
>performance considerably, but it should actually worsen performance over
>time.  
>
If you look at the test-case-code, you'll see that the methods get 
called 2000000 times, before the time is taken, so any inlining should 
have been made by then.

>The reason is that after inlining, this becomes a JVM tableswitch
>operation followed by a constant shift and bitmask.  Further optimization
>may even get rid of the tableswitch depending on JVM.
>
Whereas my method becomes some 4 asm instructions. I do not really know 
what kind of optimizations, the JVMs do, besides method inlining / 
compiling to native code, but I guess, that any branching instruction 
(which the tableswitch is) is always much slower than simple arithmetic 
instructions.

But to cut this discussion short: I looked into the code some more and 
realized, that R can only be 0 or 3. So I replaced the method with 2 
methods and optimized some more. This way only 2 operations are needed, 
to calculate the value of 2*_b() ...

The code seems to work, but since errors in encryption are hard to trace 
later, I'll do some more tests and performance evaluation tomorrow ... 
(if you are interested in including it ...)

Niklas

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: patch2.txt
URL: 
<https://emu.freenetproject.org/pipermail/devl/attachments/20020110/b7927b36/attachment.txt>

Reply via email to