3v4l.org

run code in 300+ PHP versions simultaneously
<?php function init(&$select, &$params){ $select = array('key'=>1, 'key2'=>'one', 'key3'=>3333.333); $params = array(); } //echo 'array_walk: '; init($select, $params); $start_time = microtime(TRUE); array_walk($select, function(&$val, $id) { $params[$id] = $val; $val = "{$id} = :{$id}"; }); $end_time = microtime(TRUE); $walk_time = $end_time - $start_time; //echo 'foreach: '; init($select, $params); $start_time = microtime(TRUE); foreach($select as $id => &$val){ $params[$id] = $val; $val = "{$id} = :{$id}"; }unset($val); $end_time = microtime(TRUE); $foreach_time = $end_time - $start_time; echo "<pre> ArrayWalk Time: ".sprintf('%.10F', $walk_time)." Foreach Time: ".sprintf('%.10F', $foreach_time)." array_walk > foreach: ".($walk_time > $foreach_time)." foreach > array_walk ".($foreach_time > $walk_time)."</pre>"; ?><div style="border: 1px solid gray; width: 640px; background-color: #F0F0F0"> Source Code<br><?PHP highlight_file(__FILE__); ?></div><?PHP
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 125) Position 1 = 28, Position 2 = 37
Branch analysis from position: 28
2 jumps found. (Code = 126) Position 1 = 29, Position 2 = 37
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 37
filename:       /in/oL6SF
function name:  (null)
number of ops:  70
compiled vars:  !0 = $select, !1 = $params, !2 = $start_time, !3 = $end_time, !4 = $walk_time, !5 = $val, !6 = $id, !7 = $foreach_time
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   INIT_FCALL                                               'init'
          1        SEND_REF                                                 !0
          2        SEND_REF                                                 !1
          3        DO_FCALL                                      0          
   10     4        INIT_FCALL                                               'microtime'
          5        SEND_VAL                                                 <true>
          6        DO_ICALL                                         $9      
          7        ASSIGN                                                   !2, $9
   11     8        INIT_FCALL                                               'array_walk'
          9        SEND_REF                                                 !0
         10        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FoL6SF%3A11%240'
   14    11        SEND_VAL                                                 ~11
         12        DO_ICALL                                                 
   15    13        INIT_FCALL                                               'microtime'
         14        SEND_VAL                                                 <true>
         15        DO_ICALL                                         $13     
         16        ASSIGN                                                   !3, $13
   16    17        SUB                                              ~15     !3, !2
         18        ASSIGN                                                   !4, ~15
   19    19        INIT_FCALL                                               'init'
         20        SEND_REF                                                 !0
         21        SEND_REF                                                 !1
         22        DO_FCALL                                      0          
   20    23        INIT_FCALL                                               'microtime'
         24        SEND_VAL                                                 <true>
         25        DO_ICALL                                         $18     
         26        ASSIGN                                                   !2, $18
   21    27      > FE_RESET_RW                                      $20     !0, ->37
         28    > > FE_FETCH_RW                                      ~21     $20, !5, ->37
         29    >   ASSIGN                                                   !6, ~21
   22    30        ASSIGN_DIM                                               !1, !6
         31        OP_DATA                                                  !5
   23    32        ROPE_INIT                                     3  ~25     !6
         33        ROPE_ADD                                      1  ~25     ~25, '+%3D+%3A'
         34        ROPE_END                                      2  ~24     ~25, !6
         35        ASSIGN                                                   !5, ~24
   21    36      > JMP                                                      ->28
         37    >   FE_FREE                                                  $20
   24    38        UNSET_CV                                                 !5
   25    39        INIT_FCALL                                               'microtime'
         40        SEND_VAL                                                 <true>
         41        DO_ICALL                                         $28     
         42        ASSIGN                                                   !3, $28
   26    43        SUB                                              ~30     !3, !2
         44        ASSIGN                                                   !7, ~30
   31    45        INIT_FCALL                                               'sprintf'
         46        SEND_VAL                                                 '%25.10F'
         47        SEND_VAR                                                 !4
         48        DO_ICALL                                         $32     
         49        CONCAT                                           ~33     '%3Cpre%3E%0A%0AArrayWalk+Time%3A+', $32
         50        CONCAT                                           ~34     ~33, '%0A++Foreach+Time%3A+'
   32    51        INIT_FCALL                                               'sprintf'
         52        SEND_VAL                                                 '%25.10F'
         53        SEND_VAR                                                 !7
         54        DO_ICALL                                         $35     
         55        CONCAT                                           ~36     ~34, $35
         56        CONCAT                                           ~37     ~36, '%0A%0Aarray_walk+%3E+foreach%3A+'
   34    57        IS_SMALLER                                       ~38     !7, !4
         58        CONCAT                                           ~39     ~37, ~38
         59        CONCAT                                           ~40     ~39, '%0Aforeach+%3E+array_walk+'
   35    60        IS_SMALLER                                       ~41     !4, !7
         61        CONCAT                                           ~42     ~40, ~41
         62        CONCAT                                           ~43     ~42, '%3C%2Fpre%3E'
         63        ECHO                                                     ~43
   37    64        ECHO                                                     '%3Cdiv+style%3D%22border%3A+1px+solid+gray%3B+width%3A+640px%3B+background-color%3A+%23F0F0F0%22%3E%0ASource+Code%3Cbr%3E'
   39    65        INIT_FCALL                                               'highlight_file'
         66        SEND_VAL                                                 '%2Fin%2FoL6SF'
         67        DO_ICALL                                                 
   40    68        ECHO                                                     '%3C%2Fdiv%3E'
         69      > RETURN                                                   1

Function init:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/oL6SF
function name:  init
number of ops:  5
compiled vars:  !0 = $select, !1 = $params
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    3     2        ASSIGN                                                   !0, <array>
    4     3        ASSIGN                                                   !1, <array>
    5     4      > RETURN                                                   null

End of function init

Function %00%7Bclosure%7D%2Fin%2FoL6SF%3A11%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/oL6SF
function name:  {closure}
number of ops:  9
compiled vars:  !0 = $val, !1 = $id, !2 = $params
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   12     2        ASSIGN_DIM                                               !2, !1
          3        OP_DATA                                                  !0
   13     4        ROPE_INIT                                     3  ~5      !1
          5        ROPE_ADD                                      1  ~5      ~5, '+%3D+%3A'
          6        ROPE_END                                      2  ~4      ~5, !1
          7        ASSIGN                                                   !0, ~4
   14     8      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FoL6SF%3A11%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.18 ms | 1407 KiB | 23 Q