3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Test { public $member; } $object = new Test(); $array = [ "member" => 1 ]; function test_object($object, $limit) { for ($i = 0; $i < $limit; $i++) { $object->member; } } function test_array(&$array, $limit) { for ($i = 0; $i < $limit; $i++) { $array["member"]; } } $start = microtime(true); test_object($object, 1000000); printf("objects: %.6f\n", microtime(true) - $start); sleep(1); $start = microtime(true); test_array($array, 1000000); printf("arrays: %.6f\n", microtime(true) - $start); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qIrn7
function name:  (null)
number of ops:  40
compiled vars:  !0 = $object, !1 = $array, !2 = $start
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   NEW                                              $3      'Test'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $3
    8     3        ASSIGN                                                   !1, <array>
   24     4        INIT_FCALL                                               'microtime'
          5        SEND_VAL                                                 <true>
          6        DO_ICALL                                         $7      
          7        ASSIGN                                                   !2, $7
   25     8        INIT_FCALL                                               'test_object'
          9        SEND_VAR                                                 !0
         10        SEND_VAL                                                 1000000
         11        DO_FCALL                                      0          
   26    12        INIT_FCALL                                               'printf'
         13        SEND_VAL                                                 'objects%3A+%25.6f%0A'
         14        INIT_FCALL                                               'microtime'
         15        SEND_VAL                                                 <true>
         16        DO_ICALL                                         $10     
         17        SUB                                              ~11     $10, !2
         18        SEND_VAL                                                 ~11
         19        DO_ICALL                                                 
   28    20        INIT_FCALL                                               'sleep'
         21        SEND_VAL                                                 1
         22        DO_ICALL                                                 
   30    23        INIT_FCALL                                               'microtime'
         24        SEND_VAL                                                 <true>
         25        DO_ICALL                                         $14     
         26        ASSIGN                                                   !2, $14
   31    27        INIT_FCALL                                               'test_array'
         28        SEND_REF                                                 !1
         29        SEND_VAL                                                 1000000
         30        DO_FCALL                                      0          
   32    31        INIT_FCALL                                               'printf'
         32        SEND_VAL                                                 'arrays%3A+%25.6f%0A'
         33        INIT_FCALL                                               'microtime'
         34        SEND_VAL                                                 <true>
         35        DO_ICALL                                         $17     
         36        SUB                                              ~18     $17, !2
         37        SEND_VAL                                                 ~18
         38        DO_ICALL                                                 
   33    39      > RETURN                                                   1

Function test_object:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
2 jumps found. (Code = 44) Position 1 = 9, Position 2 = 4
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
2 jumps found. (Code = 44) Position 1 = 9, Position 2 = 4
Branch analysis from position: 9
Branch analysis from position: 4
filename:       /in/qIrn7
function name:  test_object
number of ops:  10
compiled vars:  !0 = $object, !1 = $limit, !2 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   13     2        ASSIGN                                                   !2, 0
          3      > JMP                                                      ->7
   14     4    >   FETCH_OBJ_R                                      ~4      !0, 'member'
          5        FREE                                                     ~4
   13     6        PRE_INC                                                  !2
          7    >   IS_SMALLER                                               !2, !1
          8      > JMPNZ                                                    ~6, ->4
   16     9    > > RETURN                                                   null

End of function test_object

Function test_array:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
2 jumps found. (Code = 44) Position 1 = 9, Position 2 = 4
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
2 jumps found. (Code = 44) Position 1 = 9, Position 2 = 4
Branch analysis from position: 9
Branch analysis from position: 4
filename:       /in/qIrn7
function name:  test_array
number of ops:  10
compiled vars:  !0 = $array, !1 = $limit, !2 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   19     2        ASSIGN                                                   !2, 0
          3      > JMP                                                      ->7
   20     4    >   FETCH_DIM_R                                      ~4      !0, 'member'
          5        FREE                                                     ~4
   19     6        PRE_INC                                                  !2
          7    >   IS_SMALLER                                               !2, !1
          8      > JMPNZ                                                    ~6, ->4
   22     9    > > RETURN                                                   null

End of function test_array

Class Test: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
137.4 ms | 1009 KiB | 18 Q