3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public $bar; public function __construct($bar) { $this->bar = $bar; } public function getBar() { return $this->bar; } public function setBar($bar) { $this->bar = $bar; } } $foo = new Foo(42); Debug::ProcessingTimeSinceLastCall(); //Without Setter and Getter for ($i = 0; $i < 1000000; $i++) { if ($foo->bar === 42) { $foo->bar = 43; } else { $foo->bar = 42; } } Debug::ProcessingTimeSinceLastCall('No Setter and Getter'); //With Getter and Setter for ($i = 0; $i < 1000000; $i++) { if ($foo->getBar() === 42) { $foo->setBar(43); } else { $foo->setBar(42); } } Debug::ProcessingTimeSinceLastCall('With Setter and Getter');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
2 jumps found. (Code = 44) Position 1 = 19, Position 2 = 8
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 36
Branch analysis from position: 36
2 jumps found. (Code = 44) Position 1 = 38, Position 2 = 24
Branch analysis from position: 38
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 32
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 35
Branch analysis from position: 35
2 jumps found. (Code = 44) Position 1 = 38, Position 2 = 24
Branch analysis from position: 38
Branch analysis from position: 24
Branch analysis from position: 32
2 jumps found. (Code = 44) Position 1 = 38, Position 2 = 24
Branch analysis from position: 38
Branch analysis from position: 24
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 14
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
2 jumps found. (Code = 44) Position 1 = 19, Position 2 = 8
Branch analysis from position: 19
Branch analysis from position: 8
Branch analysis from position: 14
2 jumps found. (Code = 44) Position 1 = 19, Position 2 = 8
Branch analysis from position: 19
Branch analysis from position: 8
filename:       /in/fea8Z
function name:  (null)
number of ops:  42
compiled vars:  !0 = $foo, !1 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   NEW                                              $2      'Foo'
          1        SEND_VAL_EX                                              42
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $2
   20     4        INIT_STATIC_METHOD_CALL                                  'Debug', 'ProcessingTimeSinceLastCall'
          5        DO_FCALL                                      0          
   23     6        ASSIGN                                                   !1, 0
          7      > JMP                                                      ->17
   24     8    >   FETCH_OBJ_R                                      ~7      !0, 'bar'
          9        IS_IDENTICAL                                             ~7, 42
         10      > JMPZ                                                     ~8, ->14
   25    11    >   ASSIGN_OBJ                                               !0, 'bar'
         12        OP_DATA                                                  43
         13      > JMP                                                      ->16
   27    14    >   ASSIGN_OBJ                                               !0, 'bar'
         15        OP_DATA                                                  42
   23    16    >   PRE_INC                                                  !1
         17    >   IS_SMALLER                                               !1, 1000000
         18      > JMPNZ                                                    ~12, ->8
   30    19    >   INIT_STATIC_METHOD_CALL                                  'Debug', 'ProcessingTimeSinceLastCall'
         20        SEND_VAL_EX                                              'No+Setter+and+Getter'
         21        DO_FCALL                                      0          
   33    22        ASSIGN                                                   !1, 0
         23      > JMP                                                      ->36
   34    24    >   INIT_METHOD_CALL                                         !0, 'getBar'
         25        DO_FCALL                                      0  $15     
         26        IS_IDENTICAL                                             $15, 42
         27      > JMPZ                                                     ~16, ->32
   35    28    >   INIT_METHOD_CALL                                         !0, 'setBar'
         29        SEND_VAL_EX                                              43
         30        DO_FCALL                                      0          
         31      > JMP                                                      ->35
   37    32    >   INIT_METHOD_CALL                                         !0, 'setBar'
         33        SEND_VAL_EX                                              42
         34        DO_FCALL                                      0          
   33    35    >   PRE_INC                                                  !1
         36    >   IS_SMALLER                                               !1, 1000000
         37      > JMPNZ                                                    ~20, ->24
   40    38    >   INIT_STATIC_METHOD_CALL                                  'Debug', 'ProcessingTimeSinceLastCall'
         39        SEND_VAL_EX                                              'With+Setter+and+Getter'
         40        DO_FCALL                                      0          
         41      > RETURN                                                   1

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

End of function __construct

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

End of function getbar

Function setbar:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fea8Z
function name:  setBar
number of ops:  4
compiled vars:  !0 = $bar
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
   15     1        ASSIGN_OBJ                                               'bar'
          2        OP_DATA                                                  !0
   16     3      > RETURN                                                   null

End of function setbar

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
172.29 ms | 1399 KiB | 13 Q