3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { protected $bar = 'baz'; public function getBar() { return $this->bar; } } $foo = new Foo; $time = microtime(true); for ($i = 0; $i <= 10000; $i++) { $ref = new ReflectionClass($foo); $property = $ref->getProperty('bar'); $property->setAccessible(true); $property->getValue($foo); } echo "REFLECTION: ", microtime(true) - $time, PHP_EOL; $time = microtime(true); for ($i = 0; $i <= 10000; $i++) { $foo->getBar(); } echo "GETTER: ", microtime(true) - $time, PHP_EOL;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
2 jumps found. (Code = 44) Position 1 = 26, Position 2 = 9
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 42
Branch analysis from position: 42
2 jumps found. (Code = 44) Position 1 = 44, Position 2 = 39
Branch analysis from position: 44
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 39
2 jumps found. (Code = 44) Position 1 = 44, Position 2 = 39
Branch analysis from position: 44
Branch analysis from position: 39
Branch analysis from position: 9
2 jumps found. (Code = 44) Position 1 = 26, Position 2 = 9
Branch analysis from position: 26
Branch analysis from position: 9
filename:       /in/nALh7
function name:  (null)
number of ops:  52
compiled vars:  !0 = $foo, !1 = $time, !2 = $i, !3 = $ref, !4 = $property
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   NEW                                              $5      'Foo'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $5
   14     3        INIT_FCALL                                               'microtime'
          4        SEND_VAL                                                 <true>
          5        DO_ICALL                                         $8      
          6        ASSIGN                                                   !1, $8
   16     7        ASSIGN                                                   !2, 0
          8      > JMP                                                      ->24
   17     9    >   NEW                                              $11     'ReflectionClass'
         10        SEND_VAR_EX                                              !0
         11        DO_FCALL                                      0          
         12        ASSIGN                                                   !3, $11
   18    13        INIT_METHOD_CALL                                         !3, 'getProperty'
         14        SEND_VAL_EX                                              'bar'
         15        DO_FCALL                                      0  $14     
         16        ASSIGN                                                   !4, $14
   19    17        INIT_METHOD_CALL                                         !4, 'setAccessible'
         18        SEND_VAL_EX                                              <true>
         19        DO_FCALL                                      0          
   20    20        INIT_METHOD_CALL                                         !4, 'getValue'
         21        SEND_VAR_EX                                              !0
         22        DO_FCALL                                      0          
   16    23        PRE_INC                                                  !2
         24    >   IS_SMALLER_OR_EQUAL                                      !2, 10000
         25      > JMPNZ                                                    ~19, ->9
   23    26    >   ECHO                                                     'REFLECTION%3A+'
         27        INIT_FCALL                                               'microtime'
         28        SEND_VAL                                                 <true>
         29        DO_ICALL                                         $20     
         30        SUB                                              ~21     $20, !1
         31        ECHO                                                     ~21
         32        ECHO                                                     '%0A'
   25    33        INIT_FCALL                                               'microtime'
         34        SEND_VAL                                                 <true>
         35        DO_ICALL                                         $22     
         36        ASSIGN                                                   !1, $22
   27    37        ASSIGN                                                   !2, 0
         38      > JMP                                                      ->42
   28    39    >   INIT_METHOD_CALL                                         !0, 'getBar'
         40        DO_FCALL                                      0          
   27    41        PRE_INC                                                  !2
         42    >   IS_SMALLER_OR_EQUAL                                      !2, 10000
         43      > JMPNZ                                                    ~27, ->39
   31    44    >   ECHO                                                     'GETTER%3A+'
         45        INIT_FCALL                                               'microtime'
         46        SEND_VAL                                                 <true>
         47        DO_ICALL                                         $28     
         48        SUB                                              ~29     $28, !1
         49        ECHO                                                     ~29
         50        ECHO                                                     '%0A'
         51      > RETURN                                                   1

Class Foo:
Function getbar:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nALh7
function name:  getBar
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   FETCH_OBJ_R                                      ~0      'bar'
          1      > RETURN                                                   ~0
   10     2*     > RETURN                                                   null

End of function getbar

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.48 ms | 1400 KiB | 15 Q