3v4l.org

run code in 300+ PHP versions simultaneously
<?php $object = new stdClass(); $object->member = 1; $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/2NuKs
function name:  (null)
number of ops:  42
compiled vars:  !0 = $object, !1 = $array, !2 = $start
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   NEW                                              $3      'stdClass'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $3
    3     3        ASSIGN_OBJ                                               !0, 'member'
          4        OP_DATA                                                  1
    5     5        ASSIGN                                                   !1, <array>
   21     6        INIT_FCALL                                               'microtime'
          7        SEND_VAL                                                 <true>
          8        DO_ICALL                                         $8      
          9        ASSIGN                                                   !2, $8
   22    10        INIT_FCALL                                               'test_object'
         11        SEND_VAR                                                 !0
         12        SEND_VAL                                                 1000000
         13        DO_FCALL                                      0          
   23    14        INIT_FCALL                                               'printf'
         15        SEND_VAL                                                 'objects%3A+%25.6f%0A'
         16        INIT_FCALL                                               'microtime'
         17        SEND_VAL                                                 <true>
         18        DO_ICALL                                         $11     
         19        SUB                                              ~12     $11, !2
         20        SEND_VAL                                                 ~12
         21        DO_ICALL                                                 
   25    22        INIT_FCALL                                               'sleep'
         23        SEND_VAL                                                 1
         24        DO_ICALL                                                 
   27    25        INIT_FCALL                                               'microtime'
         26        SEND_VAL                                                 <true>
         27        DO_ICALL                                         $15     
         28        ASSIGN                                                   !2, $15
   28    29        INIT_FCALL                                               'test_array'
         30        SEND_REF                                                 !1
         31        SEND_VAL                                                 1000000
         32        DO_FCALL                                      0          
   29    33        INIT_FCALL                                               'printf'
         34        SEND_VAL                                                 'arrays%3A+%25.6f%0A'
         35        INIT_FCALL                                               'microtime'
         36        SEND_VAL                                                 <true>
         37        DO_ICALL                                         $18     
         38        SUB                                              ~19     $18, !2
         39        SEND_VAL                                                 ~19
         40        DO_ICALL                                                 
   30    41      > 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/2NuKs
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
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   10     2        ASSIGN                                                   !2, 0
          3      > JMP                                                      ->7
   11     4    >   FETCH_OBJ_R                                      ~4      !0, 'member'
          5        FREE                                                     ~4
   10     6        PRE_INC                                                  !2
          7    >   IS_SMALLER                                               !2, !1
          8      > JMPNZ                                                    ~6, ->4
   13     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/2NuKs
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
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   16     2        ASSIGN                                                   !2, 0
          3      > JMP                                                      ->7
   17     4    >   FETCH_DIM_R                                      ~4      !0, 'member'
          5        FREE                                                     ~4
   16     6        PRE_INC                                                  !2
          7    >   IS_SMALLER                                               !2, !1
          8      > JMPNZ                                                    ~6, ->4
   19     9    > > RETURN                                                   null

End of function test_array

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.17 ms | 1009 KiB | 18 Q