3v4l.org

run code in 500+ PHP versions simultaneously
<?php class Vector { private $values; public function populate() { $this->values = range(1, 1_000_000); } public function appendMutable() { $this->values[] = 100_000_001; } public function appendImmutable() { $new = clone $this; $this->values[] = 100_000_001; } } $v = new Vector(); $v->populate(); $start = microtime(true); $v->appendMutable(); var_dump(microtime(true) - $start); $v = new Vector(); $v->populate(); $start = microtime(true); $v = $v->appendImmutable(); var_dump(microtime(true) - $start);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BEsYT
function name:  (null)
number of ops:  38
compiled vars:  !0 = $v, !1 = $start
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   20     0  E >   NEW                                                  $2      'Vector'
          1        DO_FCALL                                          0          
          2        ASSIGN                                                       !0, $2
   21     3        INIT_METHOD_CALL                                             !0, 'populate'
          4        DO_FCALL                                          0          
   22     5        INIT_FCALL                                                   'microtime'
          6        SEND_VAL                                                     <true>
          7        DO_ICALL                                             $6      
          8        ASSIGN                                                       !1, $6
   23     9        INIT_METHOD_CALL                                             !0, 'appendMutable'
         10        DO_FCALL                                          0          
   24    11        INIT_FCALL                                                   'var_dump'
         12        INIT_FCALL                                                   'microtime'
         13        SEND_VAL                                                     <true>
         14        DO_ICALL                                             $9      
         15        SUB                                                  ~10     $9, !1
         16        SEND_VAL                                                     ~10
         17        DO_ICALL                                                     
   26    18        NEW                                                  $12     'Vector'
         19        DO_FCALL                                          0          
         20        ASSIGN                                                       !0, $12
   27    21        INIT_METHOD_CALL                                             !0, 'populate'
         22        DO_FCALL                                          0          
   28    23        INIT_FCALL                                                   'microtime'
         24        SEND_VAL                                                     <true>
         25        DO_ICALL                                             $16     
         26        ASSIGN                                                       !1, $16
   29    27        INIT_METHOD_CALL                                             !0, 'appendImmutable'
         28        DO_FCALL                                          0  $18     
         29        ASSIGN                                                       !0, $18
   30    30        INIT_FCALL                                                   'var_dump'
         31        INIT_FCALL                                                   'microtime'
         32        SEND_VAL                                                     <true>
         33        DO_ICALL                                             $20     
         34        SUB                                                  ~21     $20, !1
         35        SEND_VAL                                                     ~21
         36        DO_ICALL                                                     
         37      > RETURN                                                       1

Class Vector:
Function populate:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BEsYT
function name:  populate
number of ops:  7
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    7     0  E >   INIT_FCALL                                                   'range'
          1        SEND_VAL                                                     1
          2        SEND_VAL                                                     1000000
          3        DO_ICALL                                             $1      
          4        ASSIGN_OBJ                                                   'values'
          5        OP_DATA                                                      $1
    8     6      > RETURN                                                       null

End of function populate

Function appendmutable:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BEsYT
function name:  appendMutable
number of ops:  4
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   11     0  E >   FETCH_OBJ_W                                          $0      'values'
          1        ASSIGN_DIM                                                   $0
          2        OP_DATA                                                      100000001
   12     3      > RETURN                                                       null

End of function appendmutable

Function appendimmutable:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BEsYT
function name:  appendImmutable
number of ops:  7
compiled vars:  !0 = $new
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   15     0  E >   FETCH_THIS                                           ~1      
          1        CLONE                                                ~2      ~1
          2        ASSIGN                                                       !0, ~2
   16     3        FETCH_OBJ_W                                          $4      'values'
          4        ASSIGN_DIM                                                   $4
          5        OP_DATA                                                      100000001
   17     6      > RETURN                                                       null

End of function appendimmutable

End of class Vector.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
166.13 ms | 1428 KiB | 16 Q