Forgive the top posting but since this involves statistical modelling with OP from a financial services company and the "comments" have already started flying, allow me to throw my two sticks onto the fire. It may help us here formulate a constructive response if you could dig a bit deeper into the close method and see who the big resource hog is. Also, if you can point to the speed limiting step in your alt package it may be interesting to contemplate. We really don't know too much about details of your typical use case, we won't forward your comments to IRS or SEC ( LOL). Often you do find that mundane things get taken for granted- I;ve found sometimes IO dominates instead of computation just because no one looked at the code and data gets copied many times and is moved byte by byte etc. Also, since you went to all the trouble of doing a stats analysis, and since these things are "supposed to be" deterministic, it may help to get some idea how the execution time noise appears if indeed it is a significant fraction of the average. Presumably this is things like OS, other tasks on machine if you measured "wall clock" ( not cpu time devoted to you ) and GC and other "stuff" including maybe disk and memory cache states. I would point out that depending on exactly what you are measuring, you could be seeing lots of caching hot/cold issues that could dominate the results.
________________________________ > From: [email protected] > To: [email protected] > Date: Tue, 20 Apr 2010 06:07:13 -0700 > Subject: Re: [iText-questions] performance question > > > > > > > > > > > > > > > > > > > > > And following up on point 3 – you have the source code, feel > free to modify it for your personal needs. > > > > > > > > Leonard > > > > > > > > > > > > From: Paulo Soares > [mailto:[email protected]] > > Sent: Tuesday, April 20, 2010 8:48 AM > > To: Post all your questions about iText here > > Subject: Re: [iText-questions] performance question > > > > > > > > > > > > > > Hmm, there are lies, damn lies and statistics. While I don't > dispute the 30% let's see the probable causes for this: > > > > > > > > > > > > > > > > - > iText tries to do things correctly avoiding to cut corners that will come and > bite your later. Metadata writing, appearance generation and so on. > > > > > > > > > > > > > > > > - > iText is a generic PDF library. It reads, writes and modifies PDFs. Any > library > designed with a narrower purpose can optimize the interested areas to > perform better. > > > > > > > > > > > > > > > > - > iText comes with source and can be extended, modified, altered. This implies > that a sensible and probably heavier structure must be in place to allow > that. If you have a closed source library with just a single purpose things > can > be done faster as that's all it's going to do. > > > > > > > > > > > > > > > > - > com.itextpdf.text.pdf.PdfStamperImpl.close() > is where everything is written to file, if you avoid calling this nothing will > come out. > > > > > > > > > > > > > > > > - > There are some speed and memory improvements in the pipeline but I don't > know how much % improvement will result or in what areas. > > > > > > > > > > > > > > > > Paulo > > > > > > > > > > > > > > > > > ________________________________ > > > > > > From: Azùa Giovanni (KSXD 32) [[email protected]] > > Sent: Tuesday, April 20, 2010 1:12 PM > > To: Post all your questions about iText here > > Subject: [iText-questions] performance question > > > > > > > > Hello, > > > > For a > specific Letter generation use-case I prepared a test of statistical > significance using a paired t-test for comparing the performance [1] of iText > vs a commercial PDF framework. The experiment shows that for our relevant > use-case iText underperforms by 30% with 95% confidence. > > > > I did some > further investigation of the iText code for this specific use-case and found > the following call to be among the top most expensive calls: > > > > com.itextpdf.text.pdf.PdfStamperImpl.close > (line 189) taking up to 195 milliseconds > > > > The code > that invokes such method is the following: > > > > private > static > void > appendFooter(PdfWriter writer) throws Exception { > > > > Map> String> replacements = new HashMap(); > > > > > replacements.put("ph0001", "XXXXX > XXXXX"); > > > > replacements.put("ph0002", "Head of > Customer Acquisition"); > > > > replacements.put("ph0003", "XXXXXX > XXXXXXX"); > > > replacements.put("ph0004", "Head of Customer > Satisfaction"); > > > > > > PdfReader footerReader = new PdfReader(FOOTER_PATH); > > > ByteArrayOutputStream outputStream = new > ByteArrayOutputStream(); > > > PdfStamper stamper = new PdfStamper(footerReader, outputStream); > > > > AcroFields form = stamper.getAcroFields(); > > > for > (Map.Entry entry : replacements.entrySet()) { > > > > form.setField(entry.getKey(), > entry.getValue()); > > > } > > > stamper.setFormFlattening(true); > > > stamper.close(); > > > > > > int pageOne = 1; > > > > int xOffset = 5; > > > > int yOffset = -560; > > > > PdfReader memoryReader = new PdfReader(outputStream.toByteArray()); > > > > PdfImportedPage importedPage = writer.getImportedPage(memoryReader, pageOne); > > > > PdfContentByte content = writer.getDirectContent(); > > > content.addTemplate(importedPage, xOffset, yOffset); > > } > > > > Are there > any possible rewrites to avoid the expensive call? > > > > Thanks in > advance, > > Best regards, > > > Giovanni > > > > [1] The Art > of Computer Systems Performance Analysis: Techniques for Experimental Design, > Measurement, Simulation, and Modeling > http://www.amazon.com/Art-Computer-Systems-Performance-Analysis/dp/0471503363/ref=cm_cr-mr-title > > > > ============================================================================== > > > Please access > the attached hyperlink for an important electronic communications disclaimer: > > > > http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html > > > ============================================================================== > > > > > > > > > ________________________________ > > > > > > 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. > > > > _________________________________________________________________ Hotmail has tools for the New Busy. Search, chat and e-mail from your inbox. http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_1 ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ 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/
