3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* * The example shows how to pause the timer for measuring time at different stages. * Once watch is started, we can call `pause` method to pause the watch. * If watch is paused, we can start it again to start timer. In that case, time will be added to timer. */ // Load Composer auto loader require_once "../vendor/autoload.php"; use Phpreboot\Stopwatch\StopWatch; // Create an instance of StopWatch $stopWatch = new StopWatch(); $innerIterator = 0; for ($i = 1; $i <= 10; $i++) { printf("Iteration %d starting.\n", $i); $stopWatch->start(); for ($j = 0; $j < 1000; $j++) { $innerIterator++; } $stopWatch->pause(); printf("Iteration %d watch stopped, not other task is starting..\n", $i); for ($k = 0; $k < 1000; $k++) { $timeWaster = $k; } } printf("Time taken by first loop (\$j), for %d iterations was: %f seconds.\n", $innerIterator, $stopWatch->getTime());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
2 jumps found. (Code = 44) Position 1 = 34, Position 2 = 7
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
2 jumps found. (Code = 44) Position 1 = 19, Position 2 = 15
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 27
Branch analysis from position: 31
2 jumps found. (Code = 44) Position 1 = 34, Position 2 = 7
Branch analysis from position: 34
Branch analysis from position: 7
Branch analysis from position: 27
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 27
Branch analysis from position: 31
Branch analysis from position: 27
Branch analysis from position: 15
2 jumps found. (Code = 44) Position 1 = 19, Position 2 = 15
Branch analysis from position: 19
Branch analysis from position: 15
filename:       /in/GFDHf
function name:  (null)
number of ops:  42
compiled vars:  !0 = $stopWatch, !1 = $innerIterator, !2 = $i, !3 = $j, !4 = $k, !5 = $timeWaster
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   INCLUDE_OR_EVAL                                          '..%2Fvendor%2Fautoload.php', REQUIRE_ONCE
   15     1        NEW                                              $7      'Phpreboot%5CStopwatch%5CStopWatch'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $7
   17     4        ASSIGN                                                   !1, 0
   19     5        ASSIGN                                                   !2, 1
          6      > JMP                                                      ->32
   20     7    >   INIT_FCALL                                               'printf'
          8        SEND_VAL                                                 'Iteration+%25d+starting.%0A'
          9        SEND_VAR                                                 !2
         10        DO_ICALL                                                 
   22    11        INIT_METHOD_CALL                                         !0, 'start'
         12        DO_FCALL                                      0          
   23    13        ASSIGN                                                   !3, 0
         14      > JMP                                                      ->17
   24    15    >   PRE_INC                                                  !1
   23    16        PRE_INC                                                  !3
         17    >   IS_SMALLER                                               !3, 1000
         18      > JMPNZ                                                    ~17, ->15
   26    19    >   INIT_METHOD_CALL                                         !0, 'pause'
         20        DO_FCALL                                      0          
   28    21        INIT_FCALL                                               'printf'
         22        SEND_VAL                                                 'Iteration+%25d+watch+stopped%2C+not+other+task+is+starting..%0A'
         23        SEND_VAR                                                 !2
         24        DO_ICALL                                                 
   30    25        ASSIGN                                                   !4, 0
         26      > JMP                                                      ->29
   31    27    >   ASSIGN                                                   !5, !4
   30    28        PRE_INC                                                  !4
         29    >   IS_SMALLER                                               !4, 1000
         30      > JMPNZ                                                    ~23, ->27
   19    31    >   PRE_INC                                                  !2
         32    >   IS_SMALLER_OR_EQUAL                                      !2, 10
         33      > JMPNZ                                                    ~25, ->7
   35    34    >   INIT_FCALL                                               'printf'
         35        SEND_VAL                                                 'Time+taken+by+first+loop+%28%24j%29%2C+for+%25d+iterations+was%3A+%25f+seconds.%0A'
         36        SEND_VAR                                                 !1
         37        INIT_METHOD_CALL                                         !0, 'getTime'
         38        DO_FCALL                                      0  $26     
         39        SEND_VAR                                                 $26
         40        DO_ICALL                                                 
         41      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.13 ms | 1400 KiB | 15 Q