github.com/pyroscope-io/pyroscope@v0.37.3-0.20230725203016-5f6947968bd0/examples/php-fpm/php/index.php (about)

     1  <?php
     2  
     3  $timeout = getenv('EXECUTION_TIMEOUT') !== false ? (int)getenv('EXECUTION_TIMEOUT') : 120;
     4  
     5  set_time_limit($timeout);
     6  
     7  function dummy()
     8  {
     9      sleep(1);
    10  }
    11  
    12  function work(int $n)
    13  {
    14      for ($i = 0; $i < $n; $i++) {
    15      }
    16  
    17      if (time() % 2 === 0) {
    18          dummy();
    19      }
    20  }
    21  
    22  function fastFunction()
    23  {
    24      work(20000000);
    25  }
    26  
    27  function slowFunction()
    28  {
    29      work(80000000);
    30  }
    31  
    32  for (; ;) {
    33      fastFunction();
    34      slowFunction();
    35  }