[ 
https://issues.apache.org/jira/browse/PDFBOX-3988?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16240143#comment-16240143
 ] 

Maciej Matecki commented on PDFBOX-3988:
----------------------------------------

Thanks. That allows me to save a few hundred ms. There's still big difference 
between first and the second page:
{code}
Page 0 rendered in 1204 ms 
Page 1 rendered in 149 ms 
{code}
Above that's the pdf file where two pages are the same. So let's say that 
something is cached and the second page is much faster.

However, if I test the pdf where each page is different results look like that:
{code}
Page 0 rendered in 1172 ms 
Page 1 rendered in 763 ms 
Page 2 rendered in 208 ms 
Page 3 rendered in 56 ms 
Page 4 rendered in 78 ms 
Page 5 rendered in 161 ms 
{code}

The interesting thing in the last commit to my small benchmark project there're 
two pdfs rendered:

{code}
try (PDDocument document = getPDFDocument("/test-pdf-18.pdf")) {
            renderPages(document, dpi);
            System.out.println("---------------");
        } catch (Exception e) {
            System.out.println("Ups. " + e.getMessage());
        }

        try (PDDocument document = getPDFDocument("/test-2p.pdf")) {
            renderPages(document, dpi);
            System.out.println("---------------");
        } catch (Exception e) {
            System.out.println("Ups. " + e.getMessage());
        }
{code}

And the results looks like that:
{code}
Page 0 rendered in 1083 ms 
Page 1 rendered in 718 ms 
Page 2 rendered in 185 ms 
Page 3 rendered in 64 ms 
Page 4 rendered in 82 ms 
Page 5 rendered in 164 ms 
Page 6 rendered in 1216 ms 
Page 7 rendered in 184 ms 
Page 8 rendered in 104 ms 
Page 9 rendered in 99 ms 
Page 10 rendered in 112 ms 
---------------
Page 0 rendered in 123 ms 
Page 1 rendered in 113 ms 
---------------
{code}

So the first page of the second PDF is rendered really quickly.

Is there something more to initialize earlier so later results are better?


> Performance issue when rendering first page of PDF
> --------------------------------------------------
>
>                 Key: PDFBOX-3988
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-3988
>             Project: PDFBox
>          Issue Type: Improvement
>          Components: Rendering
>    Affects Versions: 2.0.7
>            Reporter: Maciej Matecki
>         Attachments: calls.png
>
>
> Let say that you want to generate PNG for all pages in PDF.
> The generation of the first page is really slow, the second one is quite fast.
> For example test PDF contains two same PDF pages. 
> First page renders in: ~2000ms
> Second one: ~220 ms
> It looks like for the first page (inv.0) there's 359 ms overhead just for 
> creating the font.
> [^calls.png]
> Tried to use other library to perform the same operation with the same pdf 
> file and I was able to retrieve BufferedImage of the first (slower) page in 
> ~750 ms.
> For the second page the result was almost the same like for the PDFBox.
> It looks like there's the place to improve performance when starting 
> rendering the PDF page. 
> Or do you have any advices how to improve performance in the example project?
> Test project: https://github.com/mmatecki/pdfboxperformance



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: dev-h...@pdfbox.apache.org

Reply via email to