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

Alfred commented on PDFBOX-4877:
--------------------------------

It's indeed better.

Your version executes in 1900ms, compared to my 2200ms and the original 4200ms.

And this version executes in 1500ms, probably because it skips the array 
instantiation logic:
{code:java}
public Matrix multiply( Matrix other )
{
    return multiply(other, new Matrix());
}

public Matrix multiply( Matrix other, Matrix result )
{
    float[] c = result.single;

    multiplyArrays(single, other.single, c);

    if (!Float.isFinite(c[0]) || !Float.isFinite(c[1]) || !Float.isFinite(c[2])
            || !Float.isFinite(c[3]) || !Float.isFinite(c[4]) || 
!Float.isFinite(c[5])
            || !Float.isFinite(c[6]) || !Float.isFinite(c[7]) || 
!Float.isFinite(c[8]))
        throw new IllegalArgumentException("Multiplying two matrices produces 
illegal values");

    return result;
}
{code}
And the interesting part is, the #multiply( Matrix other, Matrix result ) is 
not even used in the code, it is used only in unit tests.

> Matrix class performance improvements
> -------------------------------------
>
>                 Key: PDFBOX-4877
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-4877
>             Project: PDFBox
>          Issue Type: Improvement
>          Components: Parsing, Text extraction
>    Affects Versions: 2.0.20, 3.0.0 PDFBox
>            Reporter: Alfred
>            Assignee: Andreas Lehmkühler
>            Priority: Major
>              Labels: Optimization
>         Attachments: PDFBOX-4877.patch
>
>   Original Estimate: 1m
>  Remaining Estimate: 1m
>
> I am testing text extraction from PDF and profiling the execution.
> I found that the third major time consumer is with matrix multiplicaitons.
> The Matrix class spends large amounts of time copying results to new 
> instances. 
> Also, the if statements are slowing down execution as they kill performance 
> in modern CPUs.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

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

Reply via email to