diff options
author | Tyson Andre <tysonandre775@hotmail.com> | 2021-02-12 19:42:03 -0500 |
---|---|---|
committer | Tyson Andre <tysonandre775@hotmail.com> | 2021-02-13 09:34:48 -0500 |
commit | 8ffc20ace6c8a59b30aea53e2100aa26e4f1f3ee (patch) | |
tree | 2d1a5e510b68167be1ab86dd2ea48ad2bc59ac92 /sapi/cgi/cgi_main.stub.php | |
parent | f74a02d263aa332d995f78bd71878012952623b1 (diff) | |
download | php-git-8ffc20ace6c8a59b30aea53e2100aa26e4f1f3ee.tar.gz |
Optimize Traversable unpacking in zend_vm_def.h
The C compiler sees that a dynamic function is being called, so it cannot infer
that iter->funcs has not changed.
This results in more assembly instructions and slightly more time to execute that code
path.
Unpacking traversables to arrays(`ZEND_ADD_ARRAY_UNPACK`),
starting foreach loops (`ZEND_FE_FETCH*`), etc. are affected.
```
<?php
/*
* Before: 1.576 seconds
* After: 1.474 seconds
*/
function example() {
$start = hrtime(true);
$it = new SplFixedArray(1000);
$total = 0;
for ($i = 0; $i < 100000; $i++) {
$total += count([...$it]);
}
$end = hrtime(true);
printf("Elapsed: %.6f\n", ($end - $start) / 1_000_000_000);
}
example();
```
Diffstat (limited to 'sapi/cgi/cgi_main.stub.php')
0 files changed, 0 insertions, 0 deletions