[ https://issues.apache.org/jira/browse/PDFBOX-2117?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14058549#comment-14058549 ]
Petr Slaby commented on PDFBOX-2117: ------------------------------------ Just a hint or question. At the end of getRaster(), the cached values are always unnormalized by e.g. (int) (values[0] * 255). Why not cache the unnormalized values right away, then? You could put the three values into a single int to reduce memory consumption and to avoid the c.clone() in ColorRGB. But maybe I missed something, I did not really try to change the code this way. As for the comparison of the three methods of implementing AxialShadingContext, the scan line precomputation is the fastest of course, especially as it only counts the values at positions rounded to an int. I have run the test again on three files that use the axial shading and measured total time spent in the constructor and getRaster(). The times are in milliseconds. ||File||Trunk||Shaola||My patch|| |shading_pattern.pdf|67055|557|1534| |color_gradient.pdf|72622|1002|2461| |missing_image.pdf|34897|376|29672| > AxialShadingContext is slow > --------------------------- > > Key: PDFBOX-2117 > URL: https://issues.apache.org/jira/browse/PDFBOX-2117 > Project: PDFBox > Issue Type: Sub-task > Components: Rendering > Reporter: Petr Slaby > Attachments: 000001_MTEXT_CS6.pdf, AxialShading.patch, > AxialShading1.patch, AxialShadingContext.java.getrgbimage, > GWG061_Shading_x1a.pdf, GWG061_Shading_x1a.pdf-1.png, > GWG061_Shading_x1a.pdf-1.png-diff.png, Shading2Function2.pdf, > Shading2Function2.ps, Shading2Function2text.pdf, asy-shade.pdf, > color_gradient.pdf, shading_pattern.pdf > > > AxialShadingContext#getRaster() is on top of profiler hot spots in documents > that use an axial shading. Inside it, the slowest part is calling > PDColorSpaceRGB#toRGB() and PDFunctionType3#eval() (in this order). > -- This message was sent by Atlassian JIRA (v6.2#6252)