Open staabm opened 1 week ago
It's mostly an internal option for re-running tests in the face of JIT (where you want the second run to be fully JITed). Is there any use case except for run-tests to need it?
we discuss this php-src option while thinking about a --repeat
option for PHPUnit in https://github.com/sebastianbergmann/phpunit/issues/5718.
so yeah, we think about suggesting to the PHPUnit users to use php-src php --repeat=10 phpunit mytest.php
so we don't need to re-implement it in PHPUnit itself (but we don't want to advertise a php-src internal option)
Has apparently been introduced by #6365; considering the long time we have it, we may make it official.
Is there a purpose for it in userland? If we make it official, it might be impossible to improve further for internal purposes (at least without introducing more flags). E.g. it might be useful to repeat the script without clearing the pointer map. This would expose missed handling of certain conditions in optimized paths in the VM. These are often missed in tests, because they require two executions, one to fill the cache slots and another to run the optimized paths.
@staabm Is there a specific advantage specifying php --repeat=N
over for n in 1..N; do php; done
?
From my perspective, I'd rather include such a feature directly in phpunit, which tell would allow proper handling, like abort on first failure, giving an overview of all N runs at the end etc.?
We discuss this ideas and implications and expectations in https://github.com/sebastianbergmann/phpunit/issues/5718
Thanks for providing your opinions
Is there a specific advantage specifying
php --repeat=N
overfor n in 1..N; do php; done
?
Performance, due to avoiding the PHP startup. An extreme case on Windows:
> type test.php
<?php
echo "hello world\n";
> hyperfine.exe "php --repeat 10 test.php" "for /l %i in (1,1,10) do @php test.php"
Benchmark 1: php --repeat 10 test.php
Time (mean ± σ): 52.5 ms ± 2.0 ms [User: 19.6 ms, System: 31.7 ms]
Range (min … max): 49.6 ms … 59.1 ms 46 runs
Benchmark 2: for /l %i in (1,1,10) do @php test.php
Time (mean ± σ): 465.0 ms ± 4.5 ms [User: 159.1 ms, System: 300.0 ms]
Range (min … max): 459.5 ms … 472.5 ms 10 runs
Summary
php --repeat 10 test.php ran
8.86 ± 0.35 times faster than for /l %i in (1,1,10) do @php test.php
This is most noticeable for very short scripts. Most real-world applications would dwarf startup-time, it seems.
Description
While discussing stuff at the PHPUnit codesprint we stumbled over a comment mentioning the
--repeat
cli option.running e.g.
php --repeat=10 -r 'echo "hello";'
yieldsit works the same way with
php --repeat=10 -f myfile.php
this option was something noone of the people in the room has every seen/used.
we are wondering...
php --help
doesn't mention this optionphp --r<TAB>
does not autocomplete this optionPHP Version
PHP 8.3.12 (cli) (built: Sep 24 2024 18:08:04) (NTS)
Operating System
macos 15