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 < 1; $i++) { $obj = new $class_name(); $obj->foo = 42; echo $obj->foo; } return microtime(TRUE) - $start_time; } 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/1vL7X
function name:  (null)
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   INIT_FCALL                                               'printf'
          1        SEND_VAL                                                 'EmptySetter%3A+%25.2f+seconds%0A'
          2        INIT_FCALL                                               'benchmark'
          3        SEND_VAL                                                 'EmptySetter'
          4        DO_FCALL                                      0  $0      
          5        SEND_VAR                                                 $0
          6        DO_ICALL                                                 
          7      > RETURN                                                   1

Function benchmark:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 7
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 7
Branch analysis from position: 18
Branch analysis from position: 7
filename:       /in/1vL7X
function name:  benchmark
number of ops:  24
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                                                      ->16
   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
   18    13        FETCH_OBJ_R                                      ~12     !3, 'foo'
         14        ECHO                                                     ~12
   15    15        PRE_INC                                                  !2
         16    >   IS_SMALLER                                               !2, 1
         17      > JMPNZ                                                    ~14, ->7
   20    18    >   INIT_FCALL                                               'microtime'
         19        SEND_VAL                                                 <true>
         20        DO_ICALL                                         $15     
         21        SUB                                              ~16     $15, !1
         22      > RETURN                                                   ~16
   21    23*     > 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/1vL7X
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/1vL7X
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:
134.03 ms | 1403 KiB | 18 Q