Die Ausführungszeit von PHP-Terminalskripten unterscheidet sich zwischen dem ersten und den nachfolgenden Aufrufen [gesc
Posted: 23 Dec 2024, 11:35
Ich habe ein PHP-Testskript, das mehrere Aufrufe an eine String-Parsing- und Auswertungsfunktion durchführt, um sie in mehreren Fällen zu testen. Die Ausführungszeit jeder String-Auswertung (jedes einzelnen Tests) wird einzeln abgerufen, abschließend werden einzelne Zeiten summiert und die Gesamtrechenzeit angezeigt:
administrator@Mac-di-Paolo test % php formula-run-tests.php
All 94 tests passed!
Elapsed time: 1.332 ms.
Worst is at line 56 and took 34µs to run.
administrator@Mac-di-Paolo test % php formula-run-tests.php
All 94 tests passed!
Elapsed time: 1.085 ms.
Worst is at line 56 and took 43µs to run.
administrator@Mac-di-Paolo test % php formula-run-tests.php
All 94 tests passed!
Elapsed time: 1.056 ms.
Worst is at line 106 and took 36µs to run.
administrator@Mac-di-Paolo test %
Warum ist die Gesamtzeit bei der ersten Ausführung 20–50 % länger als bei nachfolgenden Ausführungen?
Wenn ich etwa 5 Minuten warte, verlangsamt sich die Ausführung wieder herunter, um beim nächsten Aufruf wieder die Höchstgeschwindigkeit zu erreichen.
☯ macOS 14.3
PHP 8.2.7< /p>
MacBook Air M3
administrator@Mac-di-Paolo test % php formula-run-tests.php
All 94 tests passed!
Elapsed time: 1.332 ms.
Worst is at line 56 and took 34µs to run.
administrator@Mac-di-Paolo test % php formula-run-tests.php
All 94 tests passed!
Elapsed time: 1.085 ms.
Worst is at line 56 and took 43µs to run.
administrator@Mac-di-Paolo test % php formula-run-tests.php
All 94 tests passed!
Elapsed time: 1.056 ms.
Worst is at line 106 and took 36µs to run.
administrator@Mac-di-Paolo test %
Warum ist die Gesamtzeit bei der ersten Ausführung 20–50 % länger als bei nachfolgenden Ausführungen?
Wenn ich etwa 5 Minuten warte, verlangsamt sich die Ausführung wieder herunter, um beim nächsten Aufruf wieder die Höchstgeschwindigkeit zu erreichen.
☯ macOS 14.3