3v4l.org

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

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

End of function __set

End of class NonEmptySetter.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.21 ms | 1402 KiB | 19 Q