3v4l.org

run code in 300+ PHP versions simultaneously
<?php class SomeClass { static function doTest($var) {return $var;} } class SomeObj { function doTest($var) {return $var;} static function doTest2($var) {return $var;} } //bench static call $starttime = microtime(true); for ($i = 0; $i< 100000; $i++) SomeClass::doTest($i); echo "Static call time: " , (microtime(true)-$starttime) , " ms "; //bench object method $starttime = microtime(true); $obj = new SomeObj(); for ($i = 0; $i< 100000; $i++) $obj->doTest($i); echo "Object method call time: " , (microtime(true)-$starttime) , " ms "; //bench static call $starttime = microtime(true); for ($i = 0; $i< 100000; $i++) SomeObj::doTest2($i); echo "Static call (when the static is in the same class of object method) time: " , (microtime(true)-$starttime) , " ms ";
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 = 6
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
2 jumps found. (Code = 44) Position 1 = 34, Position 2 = 28
Branch analysis from position: 34
1 jumps found. (Code = 42) Position 1 = 51
Branch analysis from position: 51
2 jumps found. (Code = 44) Position 1 = 53, Position 2 = 47
Branch analysis from position: 53
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 47
2 jumps found. (Code = 44) Position 1 = 53, Position 2 = 47
Branch analysis from position: 53
Branch analysis from position: 47
Branch analysis from position: 28
2 jumps found. (Code = 44) Position 1 = 34, Position 2 = 28
Branch analysis from position: 34
Branch analysis from position: 28
Branch analysis from position: 6
2 jumps found. (Code = 44) Position 1 = 12, Position 2 = 6
Branch analysis from position: 12
Branch analysis from position: 6
filename:       /in/aYnuF
function name:  (null)
number of ops:  61
compiled vars:  !0 = $starttime, !1 = $i, !2 = $obj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   INIT_FCALL                                               'microtime'
          1        SEND_VAL                                                 <true>
          2        DO_ICALL                                         $3      
          3        ASSIGN                                                   !0, $3
   17     4        ASSIGN                                                   !1, 0
          5      > JMP                                                      ->10
   18     6    >   INIT_STATIC_METHOD_CALL                                  'SomeClass', 'doTest'
          7        SEND_VAR                                                 !1
          8        DO_FCALL                                      0          
   17     9        PRE_INC                                                  !1
         10    >   IS_SMALLER                                               !1, 100000
         11      > JMPNZ                                                    ~8, ->6
   19    12    >   ECHO                                                     'Static+call+time%3A+'
         13        INIT_FCALL                                               'microtime'
         14        SEND_VAL                                                 <true>
         15        DO_ICALL                                         $9      
         16        SUB                                              ~10     $9, !0
         17        ECHO                                                     ~10
         18        ECHO                                                     '+ms%0A'
   23    19        INIT_FCALL                                               'microtime'
         20        SEND_VAL                                                 <true>
         21        DO_ICALL                                         $11     
         22        ASSIGN                                                   !0, $11
   24    23        NEW                                              $13     'SomeObj'
         24        DO_FCALL                                      0          
         25        ASSIGN                                                   !2, $13
   25    26        ASSIGN                                                   !1, 0
         27      > JMP                                                      ->32
   26    28    >   INIT_METHOD_CALL                                         !2, 'doTest'
         29        SEND_VAR_EX                                              !1
         30        DO_FCALL                                      0          
   25    31        PRE_INC                                                  !1
         32    >   IS_SMALLER                                               !1, 100000
         33      > JMPNZ                                                    ~19, ->28
   27    34    >   ECHO                                                     'Object+method+call+time%3A+'
         35        INIT_FCALL                                               'microtime'
         36        SEND_VAL                                                 <true>
         37        DO_ICALL                                         $20     
         38        SUB                                              ~21     $20, !0
         39        ECHO                                                     ~21
         40        ECHO                                                     '+ms%0A'
   31    41        INIT_FCALL                                               'microtime'
         42        SEND_VAL                                                 <true>
         43        DO_ICALL                                         $22     
         44        ASSIGN                                                   !0, $22
   32    45        ASSIGN                                                   !1, 0
         46      > JMP                                                      ->51
   33    47    >   INIT_STATIC_METHOD_CALL                                  'SomeObj', 'doTest2'
         48        SEND_VAR                                                 !1
         49        DO_FCALL                                      0          
   32    50        PRE_INC                                                  !1
         51    >   IS_SMALLER                                               !1, 100000
         52      > JMPNZ                                                    ~27, ->47
   34    53    >   ECHO                                                     'Static+call+%28when+the+static+is+in+the+same+class+of+object+method%29+time%3A+'
         54        INIT_FCALL                                               'microtime'
         55        SEND_VAL                                                 <true>
         56        DO_ICALL                                         $28     
         57        SUB                                              ~29     $28, !0
         58        ECHO                                                     ~29
         59        ECHO                                                     '+ms%0A'
   35    60      > RETURN                                                   1

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

End of function dotest

End of class SomeClass.

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

End of function dotest

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

End of function dotest2

End of class SomeObj.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.06 ms | 1408 KiB | 15 Q