Don't know if it'll make any difference, but the way you are reading the file
is horribly inefficient.  If the code you wrote is part of your test times,
you might want to re-try, but using this instead (I'm just tossing this
together - there might be type-os):

ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buf = new byte[8092];
int n;
while ((n = is.read(buf)) >= 0) {
        baos.write(buf, 0, n);
}
return baos.toByteArray();


If loading the file into main memory makes any difference, that difference
will be a measure of the impact of virtual<->native interface interaction. 
In effect, this is telling us whether the calls to file.read() should be
replaced with file.read(byte[]).



>From your results, are you seeing a big difference between iText and the
competitor when you aren't flattening fields vs you are flattening fields? 
Your profiling results aren't indicating bottlenecks in that area of the
code.  If iText is much faster than the competitor in the non-flattening
scenario, but slower than the competitor in the flattening scenario, I'm
having a hard time reconciling the data presented so far.



Giovanni Azua-2 wrote:
> 
> 
> I am sooo sorry the performance is worse with the change for pre-loading
> the PDFs in the test-case :(((((( the problem was that I ran the
> benchmarks with a small mistake in my test case ... 
> 
> Loading the HEADER demonstrates how to load flattened pre-formatted PDF
> part templates ...
> 
> Loading the FOOTER demonstrates how to load PDF part templates containing
> fields  that need to be populated.
> 
> The mistake was to leave fixed the HEADER always ... so it would load only
> the flattened PDF template and not the footer (see below) [sigh] In any
> case is good to know that loading flattened PDF parts is cheaper.
> 
> I mistakenly ran the last benchmark like this:
> 
> private static byte[] file2ByteArray(String filePath) throws Exception {
>   InputStream input = null;   
>   ByteArrayOutputStream output = null;
>   try {
>     input = new BufferedInputStream(new FileInputStream(HEADER_PATH));
>     output = new ByteArrayOutputStream();
>     int data = input.read();
>     while (data != -1) {
>       output.write(data);
>                       
>       data = input.read();
>     }
>               
>     return output.toByteArray();
>   }   
>   finally {
>     if (input != null) {
>       input.close();
>     }
>               
>     if (output != null) {
>       output.close();
>     }
>   }
> }
> ------------------------------------------------------------------------------
> 
> _______________________________________________
> iText-questions mailing list
> iText-questions@lists.sourceforge.net
> 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/
> 

-- 
View this message in context: 
http://old.nabble.com/performance-follow-up-tp28322800p28346146.html
Sent from the iText - General mailing list archive at Nabble.com.


------------------------------------------------------------------------------
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
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/

Reply via email to