You are right, I'll have a look.

Paulo 

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On 
> Behalf Of Harakiri
> Sent: Thursday, June 28, 2007 4:43 PM
> To: Post all your questions about iText here
> Subject: [iText-questions] Performance Bottleneck in 
> BaseFont.getWidth ?
> 
> Hello,
> 
> first of thanks again for a great API.
> 
> I've been doing some performance analyzing for our
> application. 
> 
> I believe there is some unneeded overhead in the
> BaseFont.getWidth method.
> 
> What it actually does is, creating thousends or
> millions of strings depending on much text input is
> within your generated PDF.
> 
> public int getWidth(char char1) {
>         if (fastWinansi) {
>             if (char1 < 128 || (char1 >= 160 && char1
> <= 255))
>                 return widths[char1];
>             return
> widths[PdfEncodings.winansi.get(char1)];
>         }
>         return getWidth(new String(new
> char[]{char1}));
>     }
> 
> 
> The new String(new char[]{char1}) will create a String
> object just for 1 char - so that it is able to use the
> getWidth String method - however this method also only
> iterates again over characters. 
> 
> What happends (in my test szenario) is that about 20%
> CPU time is spent using multiple threads just due the
> new String() call. If, for example there would be a
> seperate method to handle single characters iText
> would be alot faster in PDF generation i believe.
> 
> This has probably been done so that you dont need 2
> methods which actually do the same things just for
> String vs char - but i suggest using 2 methods for a
> speed gain.
> 
> Attached to this message is the call graph from
> jProfiler .
> 
> What do you think ?


Aviso Legal:
Esta mensagem é destinada exclusivamente ao destinatário. Pode conter 
informação confidencial ou legalmente protegida. A incorrecta transmissão desta 
mensagem não significa a perca de confidencialidade. Se esta mensagem for 
recebida por engano, por favor envie-a de volta para o remetente e apague-a do 
seu sistema de imediato. É proibido a qualquer pessoa que não o destinatário de 
usar, revelar ou distribuir qualquer parte desta mensagem. 

Disclaimer:
This message is destined exclusively to the intended receiver. It may contain 
confidential or legally protected information. The incorrect transmission of 
this message does not mean the loss of its confidentiality. If this message is 
received by mistake, please send it back to the sender and delete it from your 
system immediately. It is forbidden to any person who is not the intended 
receiver to use, distribute or copy any part of this message.


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/

Reply via email to