Get this file: https://library.sciencemadness.org/library/books/Mellor_ACTITC_10.pdf
Then:
% time Build/lagom/bin/pdf --render out.png Mellor_ACTITC_10.pdf --page 4
Build/lagom/bin/pdf --render out.png Mellor_ACTITC_10.pdf --page 4 1.33s user 0.02s system 99% cpu 1.361 total
Running it under instruments shows that basically all time is spent decoding CCITT data:
Almost all of the time is spent in take_first(), likely the call on line 494. ReferenceLine is a Vector<Change>, so take_first is O(n). Adding -dump-contents to the invocation shows that the image is 3074 pixels wide, and this take_last probably makes something O(n^2), which for 3000 starts getting slow.
Maybe using a ReadonlySpan if possible, or a CircularQueue or something could be an easy way to improve a lot here.
@LucasChollet
Get this file: https://library.sciencemadness.org/library/books/Mellor_ACTITC_10.pdf
Then:
Running it under instruments shows that basically all time is spent decoding CCITT data:
Almost all of the time is spent in take_first(), likely the call on line 494.
ReferenceLineis aVector<Change>, so take_first is O(n). Adding-dump-contentsto the invocation shows that the image is 3074 pixels wide, and this take_last probably makes something O(n^2), which for 3000 starts getting slow.Maybe using a ReadonlySpan if possible, or a CircularQueue or something could be an easy way to improve a lot here.
@LucasChollet