sleep.php 802 B

1234567891011121314151617181920212223242526272829
  1. <?php
  2. require_once __DIR__ . '/_executor.php';
  3. return function () {
  4. $sleep = (int)($_GET['sleep'] ?? 0);
  5. $work = (int)($_GET['work'] ?? 0);
  6. $output = (int)($_GET['output'] ?? 1);
  7. $iterations = (int)($_GET['iterations'] ?? 1);
  8. for ($i = 0; $i < $iterations; $i++) {
  9. // simulate work
  10. // with 30_000 iterations we're in the range of a simple Laravel request
  11. // (without JIT and with debug symbols enabled)
  12. for ($j = 0; $j < $work; $j++) {
  13. $a = +$j;
  14. }
  15. // simulate IO, sleep x milliseconds
  16. if ($sleep > 0) {
  17. usleep($sleep * 1000);
  18. }
  19. // simulate output
  20. for ($k = 0; $k < $output; $k++) {
  21. echo "slept for $sleep ms and worked for $work iterations";
  22. }
  23. }
  24. };