Hello, On Apr 23, 2010, at 10:50 PM, trumpetinc wrote: > 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(); > I tried your suggestion above and made no significative difference compared to doing the loading from iText. The fastest I could get my use case to work using this pre-loading concept was by loading the whole file in one shot using the code below.
Applying the cumulative patch plus preloading the whole PDF using the code below, my original test-case now performs 7.74% faster than before, roughly 22% away from competitor now ... btw the average response time numbers I was getting: - average response time of 77ms original unchanged test-case from the office multi-processor-multi-core workstation - average response time of 15ms original unchanged test-case from home using my MBP I attribute the huge difference between those two similar experiments mainly to having an SSD drive in my MBP ... the top Host spots reported from the profiler are related one way or another to IO so would be no wonder that with an SSD drive the response time improves by a factor of 5x. There are other differences though e.g. OS, JVM version. Best regards, Giovanni private static byte[] file2ByteArray(String filePath) throws Exception { InputStream input = null; try { File file = new File(filePath); input = new BufferedInputStream(new FileInputStream(filePath)); byte[] buff = new byte[(int) file.length()]; input.read(buff); return buff; } finally { if (input != null) { input.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/