3v4l.org

run code in 300+ PHP versions simultaneously
<?php class EmptySetter { public function __set($name, $value) {} } class NonEmptySetter { public function __set($name, $value) { $this->{$name} = $value; } } function benchmark($obj) { $start_time = microtime(TRUE); for ($i = 0; $i < 10000000; $i++) { $obj->foo = 42; } return microtime(TRUE) - $start_time; } printf("EmptySetter: %.2f seconds\n", benchmark(new EmptySetter)); printf("NonEmptySetter: %.2f seconds\n", benchmark(new NonEmptySetter));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/V4GYr
function name:  (null)
number of ops:  19
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   INIT_FCALL                                               'printf'
          1        SEND_VAL                                                 'EmptySetter%3A+%25.2f+seconds%0A'
          2        INIT_FCALL                                               'benchmark'
          3        NEW                                              $0      'EmptySetter'
          4        DO_FCALL                                      0          
          5        SEND_VAR                                                 $0
          6        DO_FCALL                                      0  $2      
          7        SEND_VAR                                                 $2
          8        DO_ICALL                                                 
   21     9        INIT_FCALL                                               'printf'
         10        SEND_VAL                                                 'NonEmptySetter%3A+%25.2f+seconds%0A'
         11        INIT_FCALL                                               'benchmark'
         12        NEW                                              $4      'NonEmptySetter'
         13        DO_FCALL                                      0          
         14        SEND_VAR                                                 $4
         15        DO_FCALL                                      0  $6      
         16        SEND_VAR                                                 $6
         17        DO_ICALL                                                 
         18      > RETURN                                                   1

Function benchmark:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
2 jumps found. (Code = 44) Position 1 = 12, Position 2 = 7
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 44) Position 1 = 12, Position 2 = 7
Branch analysis from position: 12
Branch analysis from position: 7
filename:       /in/V4GYr
function name:  benchmark
number of ops:  18
compiled vars:  !0 = $obj, !1 = $start_time, !2 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
   13     1        INIT_FCALL                                               'microtime'
          2        SEND_VAL                                                 <true>
          3        DO_ICALL                                         $3      
          4        ASSIGN                                                   !1, $3
   14     5        ASSIGN                                                   !2, 0
          6      > JMP                                                      ->10
   15     7    >   ASSIGN_OBJ                                               !0, 'foo'
          8        OP_DATA                                                  42
   14     9        PRE_INC                                                  !2
         10    >   IS_SMALLER                                               !2, 10000000
         11      > JMPNZ                                                    ~8, ->7
   17    12    >   INIT_FCALL                                               'microtime'
         13        SEND_VAL                                                 <true>
         14        DO_ICALL                                         $9      
         15        SUB                                              ~10     $9, !1
         16      > RETURN                                                   ~10
   18    17*     > RETURN                                                   null

End of function benchmark

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

End of function __set

End of class EmptySetter.

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

End of function __set

End of class NonEmptySetter.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.92 ms | 1403 KiB | 19 Q