3v4l.org

run code in 500+ PHP versions simultaneously
<?php function measure($c) { $start = hrtime(true); $c(); var_dump(hrtime(true) - $start); } const ITERS = 10000; measure(function () { $array = []; for ($i = 0; $i < ITERS; $i++) { $array[] = $i; } }); measure(function () { $array = []; for ($i = 0; $i < ITERS; $i++) { $copy = $array; $array[] = $i; } });
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GR6On
function name:  (null)
number of ops:  10
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    9     0  E >   DECLARE_CONST                                                'ITERS', 10000
   11     1        INIT_FCALL                                                   'measure'
          2        DECLARE_LAMBDA_FUNCTION                              ~0      [0]
   17     3        SEND_VAL                                                     ~0
   11     4        DO_FCALL                                          0          
   19     5        INIT_FCALL                                                   'measure'
          6        DECLARE_LAMBDA_FUNCTION                              ~2      [1]
   26     7        SEND_VAL                                                     ~2
   19     8        DO_FCALL                                          0          
   26     9      > RETURN                                                       1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
2 jumps found. (Code = 44) Position 1 = 9, Position 2 = 3
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 9, Position 2 = 3
Branch analysis from position: 9
Branch analysis from position: 3
filename:       /in/GR6On
function name:  {closure:/in/GR6On:11}
number of ops:  10
compiled vars:  !0 = $array, !1 = $i
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   12     0  E >   ASSIGN                                                       !0, <array>
   14     1        ASSIGN                                                       !1, 0
          2      > JMP                                                          ->6
   15     3    >   ASSIGN_DIM                                                   !0
          4        OP_DATA                                                      !1
   14     5        PRE_INC                                                      !1
          6    >   FETCH_CONSTANT                                       ~6      'ITERS'
          7        IS_SMALLER                                                   !1, ~6
          8      > JMPNZ                                                        ~7, ->3
   17     9    > > RETURN                                                       null

End of Dynamic Function 0

Dynamic Function 1
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
2 jumps found. (Code = 44) Position 1 = 10, Position 2 = 3
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 10, Position 2 = 3
Branch analysis from position: 10
Branch analysis from position: 3
filename:       /in/GR6On
function name:  {closure:/in/GR6On:19}
number of ops:  11
compiled vars:  !0 = $array, !1 = $i, !2 = $copy
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   20     0  E >   ASSIGN                                                       !0, <array>
   22     1        ASSIGN                                                       !1, 0
          2      > JMP                                                          ->7
   23     3    >   ASSIGN                                                       !2, !0
   24     4        ASSIGN_DIM                                                   !0
          5        OP_DATA                                                      !1
   22     6        PRE_INC                                                      !1
          7    >   FETCH_CONSTANT                                       ~8      'ITERS'
          8        IS_SMALLER                                                   !1, ~8
          9      > JMPNZ                                                        ~9, ->3
   26    10    > > RETURN                                                       null

End of Dynamic Function 1

Function measure:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GR6On
function name:  measure
number of ops:  15
compiled vars:  !0 = $c, !1 = $start
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   RECV                                                 !0      
    4     1        INIT_FCALL                                                   'hrtime'
          2        SEND_VAL                                                     <true>
          3        DO_ICALL                                             $2      
          4        ASSIGN                                                       !1, $2
    5     5        INIT_DYNAMIC_CALL                                            !0
          6        DO_FCALL                                          0          
    6     7        INIT_FCALL                                                   'var_dump'
          8        INIT_FCALL                                                   'hrtime'
          9        SEND_VAL                                                     <true>
         10        DO_ICALL                                             $5      
         11        SUB                                                  ~6      $5, !1
         12        SEND_VAL                                                     ~6
         13        DO_ICALL                                                     
    7    14      > RETURN                                                       null

End of function measure

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
203.9 ms | 1603 KiB | 17 Q