Skip to content

Performance issue with the redundancy operations #16

@yyzdtccjdtc

Description

@yyzdtccjdtc

widths[index] = max(widths[index], cell.width);

For this line of code, it will always update the value of widths[index], even if the value of it does not change. This introduces some redundant operations.

If we change the code to this, we can eliminate these redundant operations.

if widths[index] < cell.width{
     widths[index] = cell.width;
}

According to my tests, the average execution time decreased from 6.5s to 4.8s, which is a 1.37x speedup.

Hope this information helps!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions