Optimize org.apache.myfaces.trinidadinternal.share.url.EncoderUtilsto use less
CPU time
---------------------------------------------------------------------------------------
Key: TRINIDAD-1275
URL: https://issues.apache.org/jira/browse/TRINIDAD-1275
Project: MyFaces Trinidad
Issue Type: Bug
Reporter: Stevan Malesevic
Attachments: EncodeUtils.patch
While looking at some test cases we noticed that EncoderUtils::_writeURL uses a
lot of CPU to do its work. The basic problem is that frequent calls to charAt
and calls to underlying writer to write just char or int can be very expensive.
The overall optimization idea is:
1. Instead of doing charAt do toCharArray once. This will use a little bit more
of transient memory but it will be faster
2. Instead of doing frequent writes to the writer create one StringBuilder and
work on it. Once _writeURL is done with all the transformations do the finale
write(string) to the underlying writer
In our test case we had 4200 calls to _writeURL which used 2356ms of CPU time.
With the optimizations the same number of calls uses 268ms. This is almost 9x
improvement
Attached is the patch for the changes
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.