3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Magic { private string $foo; private int $bar; public function __get($name) { return $this->$name; } public function __set($name, $value) { return $this->$name = $value; } } class ReflectionTest { private string $foo; private int $bar; } $m = new Magic; $start = microtime(true); for ($i=0;$i<100000;$i++) { $m->foo = 'foo'; $m->bar = 5; } printf('Magic Time taken: %0.4fs%s', microtime(true) - $start, PHP_EOL); $reflection = new ReflectionTest; $start = microtime(true); for ($i=0;$i<100000;$i++) { $foo = new \ReflectionProperty(ReflectionTest::class, 'foo'); $bar = new \ReflectionProperty(ReflectionTest::class, 'bar'); $foo->setAccessible(true); $bar->setAccessible(true); $foo->setValue($reflection, 'foo'); $bar->setValue($reflection, 5); } printf('Reflection Time taken: %0.4fs%s', microtime(true) - $start, PHP_EOL); $reflection = new ReflectionTest; $start = microtime(true); $foo = new \ReflectionProperty(ReflectionTest::class, 'foo'); $bar = new \ReflectionProperty(ReflectionTest::class, 'bar'); $foo->setAccessible(true); $bar->setAccessible(true); for ($i=0;$i<100000;$i++) { $foo->setValue($reflection, 'foo'); $bar->setValue($reflection, 5); } printf('Reflection Time (Cached) taken: %0.4fs%s', microtime(true) - $start, PHP_EOL);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
2 jumps found. (Code = 44) Position 1 = 16, Position 2 = 9
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 59
Branch analysis from position: 59
2 jumps found. (Code = 44) Position 1 = 61, Position 2 = 34
Branch analysis from position: 61
1 jumps found. (Code = 42) Position 1 = 104
Branch analysis from position: 104
2 jumps found. (Code = 44) Position 1 = 106, Position 2 = 95
Branch analysis from position: 106
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 95
2 jumps found. (Code = 44) Position 1 = 106, Position 2 = 95
Branch analysis from position: 106
Branch analysis from position: 95
Branch analysis from position: 34
2 jumps found. (Code = 44) Position 1 = 61, Position 2 = 34
Branch analysis from position: 61
Branch analysis from position: 34
Branch analysis from position: 9
2 jumps found. (Code = 44) Position 1 = 16, Position 2 = 9
Branch analysis from position: 16
Branch analysis from position: 9
filename:       /in/LCgG6
function name:  (null)
number of ops:  116
compiled vars:  !0 = $m, !1 = $start, !2 = $i, !3 = $reflection, !4 = $foo, !5 = $bar
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   NEW                                              $6      'Magic'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $6
   20     3        INIT_FCALL                                               'microtime'
          4        SEND_VAL                                                 <true>
          5        DO_ICALL                                         $9      
          6        ASSIGN                                                   !1, $9
   21     7        ASSIGN                                                   !2, 0
          8      > JMP                                                      ->14
   22     9    >   ASSIGN_OBJ                                               !0, 'foo'
         10        OP_DATA                                                  'foo'
   23    11        ASSIGN_OBJ                                               !0, 'bar'
         12        OP_DATA                                                  5
   21    13        PRE_INC                                                  !2
         14    >   IS_SMALLER                                               !2, 100000
         15      > JMPNZ                                                    ~15, ->9
   25    16    >   INIT_FCALL                                               'printf'
         17        SEND_VAL                                                 'Magic+Time+taken%3A+%250.4fs%25s'
         18        INIT_FCALL                                               'microtime'
         19        SEND_VAL                                                 <true>
         20        DO_ICALL                                         $16     
         21        SUB                                              ~17     $16, !1
         22        SEND_VAL                                                 ~17
         23        SEND_VAL                                                 '%0A'
         24        DO_ICALL                                                 
   27    25        NEW                                              $19     'ReflectionTest'
         26        DO_FCALL                                      0          
         27        ASSIGN                                                   !3, $19
   28    28        INIT_FCALL                                               'microtime'
         29        SEND_VAL                                                 <true>
         30        DO_ICALL                                         $22     
         31        ASSIGN                                                   !1, $22
   29    32        ASSIGN                                                   !2, 0
         33      > JMP                                                      ->59
   30    34    >   NEW                                              $25     'ReflectionProperty'
         35        SEND_VAL_EX                                              'ReflectionTest'
         36        SEND_VAL_EX                                              'foo'
         37        DO_FCALL                                      0          
         38        ASSIGN                                                   !4, $25
   31    39        NEW                                              $28     'ReflectionProperty'
         40        SEND_VAL_EX                                              'ReflectionTest'
         41        SEND_VAL_EX                                              'bar'
         42        DO_FCALL                                      0          
         43        ASSIGN                                                   !5, $28
   32    44        INIT_METHOD_CALL                                         !4, 'setAccessible'
         45        SEND_VAL_EX                                              <true>
         46        DO_FCALL                                      0          
   33    47        INIT_METHOD_CALL                                         !5, 'setAccessible'
         48        SEND_VAL_EX                                              <true>
         49        DO_FCALL                                      0          
   34    50        INIT_METHOD_CALL                                         !4, 'setValue'
         51        SEND_VAR_EX                                              !3
         52        SEND_VAL_EX                                              'foo'
         53        DO_FCALL                                      0          
   35    54        INIT_METHOD_CALL                                         !5, 'setValue'
         55        SEND_VAR_EX                                              !3
         56        SEND_VAL_EX                                              5
         57        DO_FCALL                                      0          
   29    58        PRE_INC                                                  !2
         59    >   IS_SMALLER                                               !2, 100000
         60      > JMPNZ                                                    ~36, ->34
   38    61    >   INIT_FCALL                                               'printf'
         62        SEND_VAL                                                 'Reflection+Time+taken%3A+%250.4fs%25s'
         63        INIT_FCALL                                               'microtime'
         64        SEND_VAL                                                 <true>
         65        DO_ICALL                                         $37     
         66        SUB                                              ~38     $37, !1
         67        SEND_VAL                                                 ~38
         68        SEND_VAL                                                 '%0A'
         69        DO_ICALL                                                 
   40    70        NEW                                              $40     'ReflectionTest'
         71        DO_FCALL                                      0          
         72        ASSIGN                                                   !3, $40
   41    73        INIT_FCALL                                               'microtime'
         74        SEND_VAL                                                 <true>
         75        DO_ICALL                                         $43     
         76        ASSIGN                                                   !1, $43
   42    77        NEW                                              $45     'ReflectionProperty'
         78        SEND_VAL_EX                                              'ReflectionTest'
         79        SEND_VAL_EX                                              'foo'
         80        DO_FCALL                                      0          
         81        ASSIGN                                                   !4, $45
   43    82        NEW                                              $48     'ReflectionProperty'
         83        SEND_VAL_EX                                              'ReflectionTest'
         84        SEND_VAL_EX                                              'bar'
         85        DO_FCALL                                      0          
         86        ASSIGN                                                   !5, $48
   44    87        INIT_METHOD_CALL                                         !4, 'setAccessible'
         88        SEND_VAL_EX                                              <true>
         89        DO_FCALL                                      0          
   45    90        INIT_METHOD_CALL                                         !5, 'setAccessible'
         91        SEND_VAL_EX                                              <true>
         92        DO_FCALL                                      0          
   46    93        ASSIGN                                                   !2, 0
         94      > JMP                                                      ->104
   47    95    >   INIT_METHOD_CALL                                         !4, 'setValue'
         96        SEND_VAR_EX                                              !3
         97        SEND_VAL_EX                                              'foo'
         98        DO_FCALL                                      0          
   48    99        INIT_METHOD_CALL                                         !5, 'setValue'
        100        SEND_VAR_EX                                              !3
        101        SEND_VAL_EX                                              5
        102        DO_FCALL                                      0          
   46   103        PRE_INC                                                  !2
        104    >   IS_SMALLER                                               !2, 100000
        105      > JMPNZ                                                    ~57, ->95
   51   106    >   INIT_FCALL                                               'printf'
        107        SEND_VAL                                                 'Reflection+Time+%28Cached%29+taken%3A+%250.4fs%25s'
        108        INIT_FCALL                                               'microtime'
        109        SEND_VAL                                                 <true>
        110        DO_ICALL                                         $58     
        111        SUB                                              ~59     $58, !1
        112        SEND_VAL                                                 ~59
        113        SEND_VAL                                                 '%0A'
        114        DO_ICALL                                                 
        115      > RETURN                                                   1

Class Magic:
Function __get:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LCgG6
function name:  __get
number of ops:  4
compiled vars:  !0 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    7     1        FETCH_OBJ_R                                      ~1      !0
          2      > RETURN                                                   ~1
    8     3*     > RETURN                                                   null

End of function __get

Function __set:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LCgG6
function name:  __set
number of ops:  6
compiled vars:  !0 = $name, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   10     2        ASSIGN_OBJ                                       ~2      !0
          3        OP_DATA                                                  !1
          4      > RETURN                                                   ~2
   11     5*     > RETURN                                                   null

End of function __set

End of class Magic.

Class ReflectionTest: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.57 ms | 1012 KiB | 15 Q