3v4l.org

run code in 500+ PHP versions simultaneously
<?php class Cl { public $v = ['foo']; public function a(): array { return $this->v; } public function &b(): array { return $this->v; } } $o = new Cl(); $iters = 1_000_000; $t = microtime(true); for ($i = 0; $i < $iters; $i++) { $v1 = $o->a(); $v2 = $o->a(); $v3 = $o->a(); $v4 = $o->a(); $v1 = $o->a(); $v2 = $o->a(); $v3 = $o->a(); $v4 = $o->a(); } var_dump(microtime(true) - $t); $t = microtime(true); for ($i = 0; $i < $iters; $i++) { $v1 = $o->b(); $v2 = $o->b(); $v3 = $o->b(); $v4 = $o->b(); $v1 = $o->b(); $v2 = $o->b(); $v3 = $o->b(); $v4 = $o->b(); } var_dump(microtime(true) - $t);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 35
Branch analysis from position: 35
2 jumps found. (Code = 44) Position 1 = 37, Position 2 = 10
Branch analysis from position: 37
1 jumps found. (Code = 42) Position 1 = 75
Branch analysis from position: 75
2 jumps found. (Code = 44) Position 1 = 77, Position 2 = 50
Branch analysis from position: 77
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 50
2 jumps found. (Code = 44) Position 1 = 77, Position 2 = 50
Branch analysis from position: 77
Branch analysis from position: 50
Branch analysis from position: 10
2 jumps found. (Code = 44) Position 1 = 37, Position 2 = 10
Branch analysis from position: 37
Branch analysis from position: 10
filename:       /in/npLfI
function name:  (null)
number of ops:  85
compiled vars:  !0 = $o, !1 = $iters, !2 = $t, !3 = $i, !4 = $v1, !5 = $v2, !6 = $v3, !7 = $v4
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   17     0  E >   NEW                                                  $8      'Cl'
          1        DO_FCALL                                          0          
          2        ASSIGN                                                       !0, $8
   18     3        ASSIGN                                                       !1, 1000000
   20     4        INIT_FCALL                                                   'microtime'
          5        SEND_VAL                                                     <true>
          6        DO_ICALL                                             $12     
          7        ASSIGN                                                       !2, $12
   21     8        ASSIGN                                                       !3, 0
          9      > JMP                                                          ->35
   22    10    >   INIT_METHOD_CALL                                             !0, 'a'
         11        DO_FCALL                                          0  $15     
         12        ASSIGN                                                       !4, $15
   23    13        INIT_METHOD_CALL                                             !0, 'a'
         14        DO_FCALL                                          0  $17     
         15        ASSIGN                                                       !5, $17
   24    16        INIT_METHOD_CALL                                             !0, 'a'
         17        DO_FCALL                                          0  $19     
         18        ASSIGN                                                       !6, $19
   25    19        INIT_METHOD_CALL                                             !0, 'a'
         20        DO_FCALL                                          0  $21     
         21        ASSIGN                                                       !7, $21
   26    22        INIT_METHOD_CALL                                             !0, 'a'
         23        DO_FCALL                                          0  $23     
         24        ASSIGN                                                       !4, $23
   27    25        INIT_METHOD_CALL                                             !0, 'a'
         26        DO_FCALL                                          0  $25     
         27        ASSIGN                                                       !5, $25
   28    28        INIT_METHOD_CALL                                             !0, 'a'
         29        DO_FCALL                                          0  $27     
         30        ASSIGN                                                       !6, $27
   29    31        INIT_METHOD_CALL                                             !0, 'a'
         32        DO_FCALL                                          0  $29     
         33        ASSIGN                                                       !7, $29
   21    34        PRE_INC                                                      !3
         35    >   IS_SMALLER                                                   !3, !1
         36      > JMPNZ                                                        ~32, ->10
   31    37    >   INIT_FCALL                                                   'var_dump'
         38        INIT_FCALL                                                   'microtime'
         39        SEND_VAL                                                     <true>
         40        DO_ICALL                                             $33     
         41        SUB                                                  ~34     $33, !2
         42        SEND_VAL                                                     ~34
         43        DO_ICALL                                                     
   33    44        INIT_FCALL                                                   'microtime'
         45        SEND_VAL                                                     <true>
         46        DO_ICALL                                             $36     
         47        ASSIGN                                                       !2, $36
   34    48        ASSIGN                                                       !3, 0
         49      > JMP                                                          ->75
   35    50    >   INIT_METHOD_CALL                                             !0, 'b'
         51        DO_FCALL                                          0  $39     
         52        ASSIGN                                                       !4, $39
   36    53        INIT_METHOD_CALL                                             !0, 'b'
         54        DO_FCALL                                          0  $41     
         55        ASSIGN                                                       !5, $41
   37    56        INIT_METHOD_CALL                                             !0, 'b'
         57        DO_FCALL                                          0  $43     
         58        ASSIGN                                                       !6, $43
   38    59        INIT_METHOD_CALL                                             !0, 'b'
         60        DO_FCALL                                          0  $45     
         61        ASSIGN                                                       !7, $45
   39    62        INIT_METHOD_CALL                                             !0, 'b'
         63        DO_FCALL                                          0  $47     
         64        ASSIGN                                                       !4, $47
   40    65        INIT_METHOD_CALL                                             !0, 'b'
         66        DO_FCALL                                          0  $49     
         67        ASSIGN                                                       !5, $49
   41    68        INIT_METHOD_CALL                                             !0, 'b'
         69        DO_FCALL                                          0  $51     
         70        ASSIGN                                                       !6, $51
   42    71        INIT_METHOD_CALL                                             !0, 'b'
         72        DO_FCALL                                          0  $53     
         73        ASSIGN                                                       !7, $53
   34    74        PRE_INC                                                      !3
         75    >   IS_SMALLER                                                   !3, !1
         76      > JMPNZ                                                        ~56, ->50
   44    77    >   INIT_FCALL                                                   'var_dump'
         78        INIT_FCALL                                                   'microtime'
         79        SEND_VAL                                                     <true>
         80        DO_ICALL                                             $57     
         81        SUB                                                  ~58     $57, !2
         82        SEND_VAL                                                     ~58
         83        DO_ICALL                                                     
         84      > RETURN                                                       1

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

End of function a

Function b:
Finding entry points
Branch analysis from position: 0
Return found
filename:       /in/npLfI
function name:  b
number of ops:  5
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   13     0  E >   FETCH_OBJ_W                                          $0      'v'
          1        VERIFY_RETURN_TYPE                                           $0
          2      > RETURN_BY_REF                                                $0
   14     3*       VERIFY_RETURN_TYPE                                           
          4*     > RETURN_BY_REF                                                null

End of function b

End of class Cl.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
128.82 ms | 487 KiB | 9 Q