-
Notifications
You must be signed in to change notification settings - Fork 749
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
Performance improvements #147
Conversation
… implicit typecasts into using identity operator
… needless concatenations into single declarations
…ependency: php >= 5.3)
…reduced repeated calculation/call of identical value/method, made in_array() checks strict, merged nested positive ifs, simplified array creation
…d repeatedly indentical declared parameters in reused variable
… is_null method call by faster comparison with null, replaced intval() calls with faster (int), extracted unchanging calculations from iteration-loop, removed unnecessary parenthesis, +declared uncaught exceptions in phpDoc
Hi, could you rebase your branche ? thanks ! |
on that same note, theres lot of places in the code where the post-increment operator should be replaced with pre-increment operator. pre-increment is pretty much always faster, in every language. it uses fewer opcodes than post-increment, and the proof that the pre-increment operator is faster in PHP, you can test it yourself: <?php
for($i=0;$i<100000000;++$i){
//heating up the cpu
// (if it uses some power saving feature, like Intel SpeedStep or AMD PowerNow!)
}
$i=0;
$PreIncrementStart=microtime(true);
for($i=0;$i<100000000;++$i){
//counting to 100 million, using pre-increment.
}
$PreIncrementEnd=microtime(true);
$i=0;
$PostIncrementStart=microtime(true);
for($i=0;$i<100000000;$i++){
//counting to 100 million, using post-increment.
}
$PostIncrementEnd=microtime(true);
$PreTime=$PreIncrementEnd-$PreIncrementStart;
$PostTime=$PostIncrementEnd-$PostIncrementStart;
if($PreTime<$PostTime){
echo "the fastest was pre-increment. (which totally makes sense, it's consistent with c/c++, and it uses fewer opcodes than the post-increment, and the `old` value is not returned, only the new value, so we don't need 2 values (old value AND new value, as the post-increment does)..)";
} else {
echo "the fastest was post-increment... i am very surprised.";
}
echo "the difference was: ".abs($PreTime-$PostTime)." seconds."; |
Hi, and sorry for the delay. |
Finally, do not rebase it. I will do the work myself, thanks for all the improvements ! |
These are a few simple performance improvements, without any functional change to html2pdf's functionality. For details see included commits.