Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve performance working with unicode fonts (#907) #1158

Merged
merged 9 commits into from
Jun 27, 2024

Conversation

andersonhc
Copy link
Collaborator

I am doing some tests using functools cache to improve performance working with unicode fonts.

test_cell/test_cell_speed_with_long_text is running 50% faster.

I will do additional tests soon.

Checklist:

  • The GitHub pipeline is OK (green),
    meaning that both pylint (static code analyzer) and black (code formatter) are happy with the changes of this PR.

  • A unit test is covering the code added / modified by this PR

  • This PR is ready to be merged

  • In case of a new feature, docstrings have been added, with also some documentation in the docs/ folder

  • A mention of the change is present in CHANGELOG.md

By submitting this pull request, I confirm that my contribution is made under the terms of the GNU LGPL 3.0 license.

@andersonhc andersonhc requested a review from gmischler as a code owner May 7, 2024 13:55
Copy link
Collaborator

@gmischler gmischler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an very interesting approach.

We should probably test this with some longish text in chinese/japanese, or with a multilingual font. I suspect that a cache size of 128 is far too small in those cases (and I don't think increasing it will hurt anything with smaller alphabets).

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.28%. Comparing base (a313586) to head (ae21192).
Report is 8 commits behind head on master.

❗ Current head ae21192 differs from pull request most recent head 335c4e7. Consider uploading reports for the commit 335c4e7 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1158      +/-   ##
==========================================
+ Coverage   93.27%   93.28%   +0.01%     
==========================================
  Files          30       30              
  Lines        9228     9250      +22     
  Branches     2103     2105       +2     
==========================================
+ Hits         8607     8629      +22     
- Misses        379      382       +3     
+ Partials      242      239       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Lucas-C
Copy link
Member

Lucas-C commented May 24, 2024

test_cell/test_cell_speed_with_long_text is running 50% faster.

Wow, that is quite an improvement!
Good job @andersonhc!
This is very promising 🙂

@andersonhc
Copy link
Collaborator Author

andersonhc commented Jun 27, 2024

Test command: pytest test/text/test_cell.py::test_cell_speed_with_long_text --durations=0

pypi (latest release)

31.18s call     test/text/test_cell.py::test_cell_speed_with_long_text
29.97s call     test/text/test_cell.py::test_cell_speed_with_long_text
31.14s call     test/text/test_cell.py::test_cell_speed_with_long_text
32.86s call     test/text/test_cell.py::test_cell_speed_with_long_text
30.16s call     test/text/test_cell.py::test_cell_speed_with_long_text

Current master:

33.94s call     test/text/test_cell.py::test_cell_speed_with_long_text
30.42s call     test/text/test_cell.py::test_cell_speed_with_long_text
28.90s call     test/text/test_cell.py::test_cell_speed_with_long_text
33.58s call     test/text/test_cell.py::test_cell_speed_with_long_text
28.47s call     test/text/test_cell.py::test_cell_speed_with_long_text

PR branch:

11.38s call     test/text/test_cell.py::test_cell_speed_with_long_text
13.46s call     test/text/test_cell.py::test_cell_speed_with_long_text
12.00s call     test/text/test_cell.py::test_cell_speed_with_long_text
11.99s call     test/text/test_cell.py::test_cell_speed_with_long_text
13.00s call     test/text/test_cell.py::test_cell_speed_with_long_text

@andersonhc andersonhc merged commit c062845 into py-pdf:master Jun 27, 2024
11 checks passed
@andersonhc andersonhc deleted the performance branch June 27, 2024 00:14
@Lucas-C
Copy link
Member

Lucas-C commented Jun 28, 2024

Thank you and good job for this @andersonhc! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants