-
Notifications
You must be signed in to change notification settings - Fork 8k
Closed as not planned
Description
Description
The following code:
<?php
$start=hrtime(true);
$code = '<?php if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only");';
$tokens = token_get_all($code);
foreach ($tokens as $token) {
if (is_array($token)) {
echo "Line {$token[2]}: ", token_name($token[0]), " ('{$token[1]}')", PHP_EOL;
}
}
$end=hrtime(true);
$eta=$end-$start;
echo $eta/1e+6; //nanoseconds to milliseconds
Resulted in this output:
...
0.116826
I feel this tokenization of small code samples is a bit slow and wonder whether there is some low hanging fruits which can be optimized?
I am using such code to optimize the performance of the PHPT Testrunne in PHPUnit via https://github.com/staabm/side-effects-detector
PHP Version
8.3.13
Operating System
ubuntu 24