3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Collection { private $a = array(); public function __construct() { for ($i = 0; $i < 100000; $i++) { $this->a[] = $i; } } public function all() { return $this->a; } } $coll = new Collection(); $start = microtime(true); foreach ($coll->all() as $k => $v) { $a[$k] = $v + 1; } echo "Completed in ", microtime(true) - $start, " Seconds\n"; $start = microtime(true); $arr = $coll->all(); foreach ($arr as $k => &$v) { $v = $v + 1; } echo "Completed in ", microtime(true) - $start, " Seconds\n";
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 16
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 16
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 16
2 jumps found. (Code = 125) Position 1 = 32, Position 2 = 37
Branch analysis from position: 32
2 jumps found. (Code = 126) Position 1 = 33, Position 2 = 37
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 37
Branch analysis from position: 16
filename:       /in/VZW6U
function name:  (null)
number of ops:  46
compiled vars:  !0 = $coll, !1 = $start, !2 = $v, !3 = $k, !4 = $a, !5 = $arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   NEW                                              $6      'Collection'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $6
   22     3        INIT_FCALL                                               'microtime'
          4        SEND_VAL                                                 <true>
          5        DO_ICALL                                         $9      
          6        ASSIGN                                                   !1, $9
   23     7        INIT_METHOD_CALL                                         !0, 'all'
          8        DO_FCALL                                      0  $11     
          9      > FE_RESET_R                                       $12     $11, ->16
         10    > > FE_FETCH_R                                       ~13     $12, !2, ->16
         11    >   ASSIGN                                                   !3, ~13
   24    12        ADD                                              ~16     !2, 1
         13        ASSIGN_DIM                                               !4, !3
         14        OP_DATA                                                  ~16
   23    15      > JMP                                                      ->10
         16    >   FE_FREE                                                  $12
   26    17        ECHO                                                     'Completed+in+'
         18        INIT_FCALL                                               'microtime'
         19        SEND_VAL                                                 <true>
         20        DO_ICALL                                         $17     
         21        SUB                                              ~18     $17, !1
         22        ECHO                                                     ~18
         23        ECHO                                                     '+Seconds%0A'
   28    24        INIT_FCALL                                               'microtime'
         25        SEND_VAL                                                 <true>
         26        DO_ICALL                                         $19     
         27        ASSIGN                                                   !1, $19
   29    28        INIT_METHOD_CALL                                         !0, 'all'
         29        DO_FCALL                                      0  $21     
         30        ASSIGN                                                   !5, $21
   30    31      > FE_RESET_RW                                      $23     !5, ->37
         32    > > FE_FETCH_RW                                      ~24     $23, !2, ->37
         33    >   ASSIGN                                                   !3, ~24
   31    34        ADD                                              ~26     !2, 1
         35        ASSIGN                                                   !2, ~26
   30    36      > JMP                                                      ->32
         37    >   FE_FREE                                                  $23
   33    38        ECHO                                                     'Completed+in+'
         39        INIT_FCALL                                               'microtime'
         40        SEND_VAL                                                 <true>
         41        DO_ICALL                                         $28     
         42        SUB                                              ~29     $28, !1
         43        ECHO                                                     ~29
         44        ECHO                                                     '+Seconds%0A'
         45      > RETURN                                                   1

Class Collection:
Function __construct:
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 = 8, Position 2 = 2
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 2
2 jumps found. (Code = 44) Position 1 = 8, Position 2 = 2
Branch analysis from position: 8
Branch analysis from position: 2
filename:       /in/VZW6U
function name:  __construct
number of ops:  9
compiled vars:  !0 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   ASSIGN                                                   !0, 0
          1      > JMP                                                      ->6
   10     2    >   FETCH_OBJ_W                                      $2      'a'
          3        ASSIGN_DIM                                               $2
          4        OP_DATA                                                  !0
    9     5        PRE_INC                                                  !0
          6    >   IS_SMALLER                                               !0, 100000
          7      > JMPNZ                                                    ~5, ->2
   12     8    > > RETURN                                                   null

End of function __construct

Function all:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VZW6U
function name:  all
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   FETCH_OBJ_R                                      ~0      'a'
          1      > RETURN                                                   ~0
   17     2*     > RETURN                                                   null

End of function all

End of class Collection.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
144.76 ms | 1400 KiB | 15 Q