I have written a test script to check performance of various constructs, when rendered by DomPDF.
I have committed it to my local fork of DomPDF: MarkMaldaba@95b59f2
I don't know if this is something you would want to merge into the main repository - if so, let me know and I will create a PR. I'll be happy to make changes, e.g. to coding style, if guidance is provided.
The script takes a simple HTML snippet (e.g. <div></div>) and creates an HTML file whose body contains many instances of this snippet (10,000 in my tests). It then renders it, outputting timing and memory usage information.
It has thrown up some interesting and (to me, at least) surprising results:
> php test_performance.php whitespace 10000
Profiling PDF generation using 'whitespace' over 10000 iterations.
STEP MEMORY USE PEAK MEMORY EXECUTION TIME
Start 1,804,688 1,806,944 0
Load 1,830,752 2,175,320 0
Render 2,835,280 3,257,656 0.046875
Output 2,836,712 3,257,656 0
> php test_performance.php empty_span 10000
Profiling PDF generation using 'empty_span' over 10000 iterations.
STEP MEMORY USE PEAK MEMORY EXECUTION TIME
Start 1,824,688 1,826,944 0
Load 1,850,752 2,260,320 0.03125
Render 31,770,448 84,405,184 5.96875
Output 31,773,232 84,405,184 0
> php test_performance.php empty_div 10000
Profiling PDF generation using 'empty_div' over 10000 iterations.
STEP MEMORY USE PEAK MEMORY EXECUTION TIME
Start 1,804,672 1,806,976 0
Load 1,830,752 2,175,360 0.015625
Render 51,269,080 168,720,384 17.15625
Output 51,271,872 168,720,384 0
> php test_performance.php break_tag 10000
Profiling PDF generation using 'break_tag' over 10000 iterations.
STEP MEMORY USE PEAK MEMORY EXECUTION TIME
Start 1,734,656 1,737,064 0
Load 1,760,736 1,877,872 0.015625
Render 36,735,072 43,800,976 82.40625
Output 36,741,832 43,800,976 0.015625
So, <span> tags are 5 times faster than <div> tags, which are nearly 5 times faster than <br> tags!
Initial take-home seems to be to avoid <br> tags, but some more research needed. I suggest this ticket be used for general discussion around this issue, with any specific actionable items being spun off as separate tickets.
(For reference, the tests were run using the current 'develop' branch using PHP 5.4.45 on Windows.)
I have written a test script to check performance of various constructs, when rendered by DomPDF.
I have committed it to my local fork of DomPDF: MarkMaldaba@95b59f2
I don't know if this is something you would want to merge into the main repository - if so, let me know and I will create a PR. I'll be happy to make changes, e.g. to coding style, if guidance is provided.
The script takes a simple HTML snippet (e.g.
<div></div>) and creates an HTML file whose body contains many instances of this snippet (10,000 in my tests). It then renders it, outputting timing and memory usage information.It has thrown up some interesting and (to me, at least) surprising results:
So,
<span>tags are 5 times faster than<div>tags, which are nearly 5 times faster than<br>tags!Initial take-home seems to be to avoid
<br>tags, but some more research needed. I suggest this ticket be used for general discussion around this issue, with any specific actionable items being spun off as separate tickets.(For reference, the tests were run using the current 'develop' branch using PHP 5.4.45 on Windows.)