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. */ 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 = 31
Branch analysis from position: 31
2 jumps found. (Code = 44) Position 1 = 33, Position 2 = 6
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 14
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
2 jumps found. (Code = 44) Position 1 = 30, Position 2 = 26
Branch analysis from position: 30
2 jumps found. (Code = 44) Position 1 = 33, Position 2 = 6
Branch analysis from position: 33
Branch analysis from position: 6
Branch analysis from position: 26
2 jumps found. (Code = 44) Position 1 = 30, Position 2 = 26
Branch analysis from position: 30
Branch analysis from position: 26
Branch analysis from position: 14
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 14
Branch analysis from position: 18
Branch analysis from position: 14
filename:       /in/V3Klg
function name:  (null)
number of ops:  41
compiled vars:  !0 = $stopWatch, !1 = $innerIterator, !2 = $i, !3 = $j, !4 = $k, !5 = $timeWaster
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   NEW                                              $6      'Phpreboot%5CStopwatch%5CStopWatch'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $6
   14     3        ASSIGN                                                   !1, 0
   16     4        ASSIGN                                                   !2, 1
          5      > JMP                                                      ->31
   17     6    >   INIT_FCALL                                               'printf'
          7        SEND_VAL                                                 'Iteration+%25d+starting.%0A'
          8        SEND_VAR                                                 !2
          9        DO_ICALL                                                 
   19    10        INIT_METHOD_CALL                                         !0, 'start'
         11        DO_FCALL                                      0          
   20    12        ASSIGN                                                   !3, 0
         13      > JMP                                                      ->16
   21    14    >   PRE_INC                                                  !1
   20    15        PRE_INC                                                  !3
         16    >   IS_SMALLER                                               !3, 1000
         17      > JMPNZ                                                    ~16, ->14
   23    18    >   INIT_METHOD_CALL                                         !0, 'pause'
         19        DO_FCALL                                      0          
   25    20        INIT_FCALL                                               'printf'
         21        SEND_VAL                                                 'Iteration+%25d+watch+stopped%2C+not+other+task+is+starting..%0A'
         22        SEND_VAR                                                 !2
         23        DO_ICALL                                                 
   27    24        ASSIGN                                                   !4, 0
         25      > JMP                                                      ->28
   28    26    >   ASSIGN                                                   !5, !4
   27    27        PRE_INC                                                  !4
         28    >   IS_SMALLER                                               !4, 1000
         29      > JMPNZ                                                    ~22, ->26
   16    30    >   PRE_INC                                                  !2
         31    >   IS_SMALLER_OR_EQUAL                                      !2, 10
         32      > JMPNZ                                                    ~24, ->6
   32    33    >   INIT_FCALL                                               'printf'
         34        SEND_VAL                                                 'Time+taken+by+first+loop+%28%24j%29%2C+for+%25d+iterations+was%3A+%25f+seconds.%0A'
         35        SEND_VAR                                                 !1
         36        INIT_METHOD_CALL                                         !0, 'getTime'
         37        DO_FCALL                                      0  $25     
         38        SEND_VAR                                                 $25
         39        DO_ICALL                                                 
         40      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
167.04 ms | 1400 KiB | 15 Q