|
For what it's worth, I have also seen PRTokeniser show up as the bottleneck on performance testing I've done with the parser.
I think that Giovanni's feedback here is quite good. I think that improvements to PRTokeniser could make a non-trivial difference to overall performance of iText. Even better, Giovanni has identified one super easy thing (move to StringBuilder, which I think we can do now that we support JRE 1.5). I also suspect that re-using a single StringBuilder instance would be simple to do, but I'll need to do a code review to make sure.
Giovanni - you can either wait until someone gets a free moment to try these changes out, or you could change the source real quick and see how much a difference a move to StringBuilder would make in your profiling results. My gut instinct is that moving to StringBuilder will have an impact, but that re-using a given StringBuilder instance probably will not - but only profiling can say for sure.
I personally am quite interested in knowing the results!
- K
----------------------- Original Message -----------------------
From: Azùa Giovanni (KSXD 32)<[email protected]>
To: "Post all your questions about iText here" <[email protected]>
Cc:
Date: Wed, 21 Apr 2010 17:53:02 +0200
Subject: Re: [iText-questions] performance question
Hello,
Just a small interesting follow up. For running the workload I posted before iText allocates a total of 18'637'142 StringBuffer instances. It is also needed a total of 4000 com.itextpdf.text.pdf.PRTokeniser instances one per com.itextpdf.text.pdf.PdfReader which is fine 2x2000: 2x (appendHeader + appendFooter) * 2000 (generatePdf calls)
Only the allocation time for StringBuffer accounts for 4% of the total workload running time ... most of these allocations come from:
com.itextpdf.text.pdf.PRTokeniser.nextToken()
com.itextpdf.text.pdf.PRTokeniser.readString()
I would really consider making StringBuffer, maybe even better StringBuilder a final attribute member of com.itextpdf.text.pdf.PRTokeniser and re-use the same instance and do the "reset" when needed i.e. call builder.setLength(0); http://java.sun.com/javase/6/docs/api/java/lang/StringBuilder.html#setLength%28int%29
Best regards,
Giovanni
==============================================================================
Please access the attached hyperlink for an important electronic communications disclaimer: http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html
============================================================================== |
------------------------------------------------------------------------------
_______________________________________________ iText-questions mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://www.itextpdf.com/book/ Check the site with examples before you ask questions: http://www.1t3xt.info/examples/ You can also search the keywords list: http://1t3xt.info/tutorials/keywords/
