3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array(); $l = 100; for($i = 0; $i< $l; $i++) { $array[$i] = md5($i); } $copy = $array; $start = microtime(true); for($i = 0; $i< $l; $i++) { $copy[$i] = $copy[$i] . ' x'; usleep(1); } echo "\nfor:" . (microtime(true) - $start); $copy = $array; $start = microtime(true); foreach ($copy as $i => $item) { $copy[$i] = $item . ' x'; usleep(1); } echo "\nforeach (ohne ref):" . (microtime(true) - $start); $copy = $array; $start = microtime(true); foreach ($copy as &$item) { $item .= ' x'; usleep(1); } echo "\nforeach (mit ref):" . (microtime(true) - $start); $copy = $array; $start = microtime(true); array_walk($copy, function (&$item, $i) { $item .= ' x'; usleep(1); }); echo "\narray_walk (mit ref):" . (microtime(true) - $start); $copy = $array; $start = microtime(true); $copy = array_map(function ($item) { usleep(1); return $item . ' x'; }, $copy); echo "\narray_map (ohne ref):" . (microtime(true) - $start);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
2 jumps found. (Code = 44) Position 1 = 12, Position 2 = 4
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 19
Branch analysis from position: 29
2 jumps found. (Code = 77) Position 1 = 41, Position 2 = 50
Branch analysis from position: 41
2 jumps found. (Code = 78) Position 1 = 42, Position 2 = 50
Branch analysis from position: 42
1 jumps found. (Code = 42) Position 1 = 41
Branch analysis from position: 41
Branch analysis from position: 50
2 jumps found. (Code = 125) Position 1 = 63, Position 2 = 69
Branch analysis from position: 63
2 jumps found. (Code = 126) Position 1 = 64, Position 2 = 69
Branch analysis from position: 64
1 jumps found. (Code = 42) Position 1 = 63
Branch analysis from position: 63
Branch analysis from position: 69
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 69
Branch analysis from position: 50
Branch analysis from position: 19
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 19
Branch analysis from position: 29
Branch analysis from position: 19
Branch analysis from position: 4
2 jumps found. (Code = 44) Position 1 = 12, Position 2 = 4
Branch analysis from position: 12
Branch analysis from position: 4
filename:       /in/th7Pu
function name:  (null)
number of ops:  110
compiled vars:  !0 = $array, !1 = $l, !2 = $i, !3 = $copy, !4 = $start, !5 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    3     1        ASSIGN                                                   !1, 100
    4     2        ASSIGN                                                   !2, 0
          3      > JMP                                                      ->10
    5     4    >   INIT_FCALL                                               'md5'
          5        SEND_VAR                                                 !2
          6        DO_ICALL                                         $10     
          7        ASSIGN_DIM                                               !0, !2
          8        OP_DATA                                                  $10
    4     9        PRE_INC                                                  !2
         10    >   IS_SMALLER                                               !2, !1
         11      > JMPNZ                                                    ~12, ->4
    8    12    >   ASSIGN                                                   !3, !0
    9    13        INIT_FCALL                                               'microtime'
         14        SEND_VAL                                                 <true>
         15        DO_ICALL                                         $14     
         16        ASSIGN                                                   !4, $14
   10    17        ASSIGN                                                   !2, 0
         18      > JMP                                                      ->27
   11    19    >   FETCH_DIM_R                                      ~18     !3, !2
         20        CONCAT                                           ~19     ~18, '+x'
         21        ASSIGN_DIM                                               !3, !2
         22        OP_DATA                                                  ~19
   12    23        INIT_FCALL                                               'usleep'
         24        SEND_VAL                                                 1
         25        DO_ICALL                                                 
   10    26        PRE_INC                                                  !2
         27    >   IS_SMALLER                                               !2, !1
         28      > JMPNZ                                                    ~22, ->19
   14    29    >   INIT_FCALL                                               'microtime'
         30        SEND_VAL                                                 <true>
         31        DO_ICALL                                         $23     
         32        SUB                                              ~24     $23, !4
         33        CONCAT                                           ~25     '%0Afor%3A', ~24
         34        ECHO                                                     ~25
   17    35        ASSIGN                                                   !3, !0
   18    36        INIT_FCALL                                               'microtime'
         37        SEND_VAL                                                 <true>
         38        DO_ICALL                                         $27     
         39        ASSIGN                                                   !4, $27
   19    40      > FE_RESET_R                                       $29     !3, ->50
         41    > > FE_FETCH_R                                       ~30     $29, !5, ->50
         42    >   ASSIGN                                                   !2, ~30
   20    43        CONCAT                                           ~33     !5, '+x'
         44        ASSIGN_DIM                                               !3, !2
         45        OP_DATA                                                  ~33
   21    46        INIT_FCALL                                               'usleep'
         47        SEND_VAL                                                 1
         48        DO_ICALL                                                 
   19    49      > JMP                                                      ->41
         50    >   FE_FREE                                                  $29
   23    51        INIT_FCALL                                               'microtime'
         52        SEND_VAL                                                 <true>
         53        DO_ICALL                                         $35     
         54        SUB                                              ~36     $35, !4
         55        CONCAT                                           ~37     '%0Aforeach+%28ohne+ref%29%3A', ~36
         56        ECHO                                                     ~37
   26    57        ASSIGN                                                   !3, !0
   27    58        INIT_FCALL                                               'microtime'
         59        SEND_VAL                                                 <true>
         60        DO_ICALL                                         $39     
         61        ASSIGN                                                   !4, $39
   28    62      > FE_RESET_RW                                      $41     !3, ->69
         63    > > FE_FETCH_RW                                              $41, !5, ->69
   29    64    >   ASSIGN_OP                                     8          !5, '+x'
   30    65        INIT_FCALL                                               'usleep'
         66        SEND_VAL                                                 1
         67        DO_ICALL                                                 
   28    68      > JMP                                                      ->63
         69    >   FE_FREE                                                  $41
   32    70        INIT_FCALL                                               'microtime'
         71        SEND_VAL                                                 <true>
         72        DO_ICALL                                         $44     
         73        SUB                                              ~45     $44, !4
         74        CONCAT                                           ~46     '%0Aforeach+%28mit+ref%29%3A', ~45
         75        ECHO                                                     ~46
   35    76        ASSIGN                                                   !3, !0
   36    77        INIT_FCALL                                               'microtime'
         78        SEND_VAL                                                 <true>
         79        DO_ICALL                                         $48     
         80        ASSIGN                                                   !4, $48
   37    81        INIT_FCALL                                               'array_walk'
         82        SEND_REF                                                 !3
         83        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Fth7Pu%3A37%240'
   40    84        SEND_VAL                                                 ~50
         85        DO_ICALL                                                 
   41    86        INIT_FCALL                                               'microtime'
         87        SEND_VAL                                                 <true>
         88        DO_ICALL                                         $52     
         89        SUB                                              ~53     $52, !4
         90        CONCAT                                           ~54     '%0Aarray_walk+%28mit+ref%29%3A', ~53
         91        ECHO                                                     ~54
   44    92        ASSIGN                                                   !3, !0
   45    93        INIT_FCALL                                               'microtime'
         94        SEND_VAL                                                 <true>
         95        DO_ICALL                                         $56     
         96        ASSIGN                                                   !4, $56
   46    97        INIT_FCALL                                               'array_map'
         98        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Fth7Pu%3A46%241'
   49    99        SEND_VAL                                                 ~58
        100        SEND_VAR                                                 !3
        101        DO_ICALL                                         $59     
   46   102        ASSIGN                                                   !3, $59
   50   103        INIT_FCALL                                               'microtime'
        104        SEND_VAL                                                 <true>
        105        DO_ICALL                                         $61     
        106        SUB                                              ~62     $61, !4
        107        CONCAT                                           ~63     '%0Aarray_map+%28ohne+ref%29%3A', ~62
        108        ECHO                                                     ~63
        109      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2Fth7Pu%3A37%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/th7Pu
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $item, !1 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   37     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   38     2        ASSIGN_OP                                     8          !0, '+x'
   39     3        INIT_FCALL                                               'usleep'
          4        SEND_VAL                                                 1
          5        DO_ICALL                                                 
   40     6      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Fth7Pu%3A37%240

Function %00%7Bclosure%7D%2Fin%2Fth7Pu%3A46%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/th7Pu
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   46     0  E >   RECV                                             !0      
   47     1        INIT_FCALL                                               'usleep'
          2        SEND_VAL                                                 1
          3        DO_ICALL                                                 
   48     4        CONCAT                                           ~2      !0, '+x'
          5      > RETURN                                                   ~2
   49     6*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Fth7Pu%3A46%241

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.77 ms | 1408 KiB | 23 Q