3v4l.org

run code in 300+ PHP versions simultaneously
<?php function profile($dump = FALSE) { static $profile; // Return the times stored in profile, then erase it if ($dump) { $temp = $profile; unset($profile); return ($temp); } $profile[] = microtime(); } // Set up a tick handler register_tick_function("profile"); // Initialize the function before the declare block profile(); // Run a block of code, throw a tick every 2nd statement declare(ticks=1) { $data = 0; ++$data; //15 $data++; //15 $data+=1; //17 $data = $data + 1; //18 } // Display the data stored in the profiler $list = profile (TRUE); $len = count($list); print_r($list); function getTime($time) { list($usec, $sec) = explode(" ", $time); return ((float)$usec + (float)$sec) * 1000000; } for ($i = 1; $i < $len; $i++) { echo getTime($list[$i]) - getTime($list[$i - 1]), PHP_EOL; } //print_r(profile (TRUE));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
2 jumps found. (Code = 44) Position 1 = 42, Position 2 = 27
Branch analysis from position: 42
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
2 jumps found. (Code = 44) Position 1 = 42, Position 2 = 27
Branch analysis from position: 42
Branch analysis from position: 27
filename:       /in/Uk8Y4
function name:  (null)
number of ops:  43
compiled vars:  !0 = $data, !1 = $list, !2 = $len, !3 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   INIT_FCALL                                               'register_tick_function'
          1        SEND_VAL                                                 'profile'
          2        DO_ICALL                                                 
   20     3        INIT_FCALL                                               'profile'
          4        DO_FCALL                                      0          
   24     5        ASSIGN                                                   !0, 0
          6        TICKS                                                    
   25     7        PRE_INC                                                  !0
          8        TICKS                                                    
   26     9        PRE_INC                                                  !0
         10        TICKS                                                    
   27    11        ASSIGN_OP                                     1          !0, 1
         12        TICKS                                                    
   28    13        ADD                                              ~10     !0, 1
         14        ASSIGN                                                   !0, ~10
         15        TICKS                                                    
   32    16        INIT_FCALL                                               'profile'
         17        SEND_VAL                                                 <true>
         18        DO_FCALL                                      0  $12     
         19        ASSIGN                                                   !1, $12
   33    20        COUNT                                            ~14     !1
         21        ASSIGN                                                   !2, ~14
   34    22        INIT_FCALL                                               'print_r'
         23        SEND_VAR                                                 !1
         24        DO_ICALL                                                 
   39    25        ASSIGN                                                   !3, 1
         26      > JMP                                                      ->40
   40    27    >   INIT_FCALL                                               'gettime'
         28        FETCH_DIM_R                                      ~18     !1, !3
         29        SEND_VAL                                                 ~18
         30        DO_FCALL                                      0  $19     
         31        INIT_FCALL                                               'gettime'
         32        SUB                                              ~20     !3, 1
         33        FETCH_DIM_R                                      ~21     !1, ~20
         34        SEND_VAL                                                 ~21
         35        DO_FCALL                                      0  $22     
         36        SUB                                              ~23     $19, $22
         37        ECHO                                                     ~23
         38        ECHO                                                     '%0A'
   39    39        PRE_INC                                                  !3
         40    >   IS_SMALLER                                               !3, !2
         41      > JMPNZ                                                    ~25, ->27
   42    42    > > RETURN                                                   1

Function profile:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 6
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Uk8Y4
function name:  profile
number of ops:  11
compiled vars:  !0 = $dump, !1 = $profile, !2 = $temp
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV_INIT                                        !0      <false>
    4     1        BIND_STATIC                                              !1
    7     2      > JMPZ                                                     !0, ->6
    8     3    >   ASSIGN                                                   !2, !1
    9     4        UNSET_CV                                                 !1
   10     5      > RETURN                                                   !2
   13     6    >   INIT_FCALL                                               'microtime'
          7        DO_ICALL                                         $5      
          8        ASSIGN_DIM                                               !1
          9        OP_DATA                                                  $5
   14    10      > RETURN                                                   null

End of function profile

Function gettime:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Uk8Y4
function name:  getTime
number of ops:  16
compiled vars:  !0 = $time, !1 = $usec, !2 = $sec
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   35     0  E >   RECV                                             !0      
   36     1        INIT_FCALL                                               'explode'
          2        SEND_VAL                                                 '+'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $3      
          5        FETCH_LIST_R                                     $4      $3, 0
          6        ASSIGN                                                   !1, $4
          7        FETCH_LIST_R                                     $6      $3, 1
          8        ASSIGN                                                   !2, $6
          9        FREE                                                     $3
   37    10        CAST                                          5  ~8      !1
         11        CAST                                          5  ~9      !2
         12        ADD                                              ~10     ~8, ~9
         13        MUL                                              ~11     ~10, 1000000
         14      > RETURN                                                   ~11
   38    15*     > RETURN                                                   null

End of function gettime

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
145.96 ms | 1403 KiB | 25 Q