3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace yii\db; class test { function formName1() { $class = get_class($this); $pos = strrpos($class, '\\'); return $pos === false ? $class : substr($class, $pos + 1); } function formName2() { $reflector = new \ReflectionClass($this); return $reflector->getShortName(); } } $test = new test; $rounds = 1000; $start = microtime(true); for($i=0; $i<$rounds; $i++) { $test->formName1(); } echo (microtime(true) - $start); echo "\n"; $start = microtime(true); for($i=0; $i<$rounds; $i++) { $test->formName2(); } echo (microtime(true) - $start);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
2 jumps found. (Code = 44) Position 1 = 15, Position 2 = 10
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
2 jumps found. (Code = 44) Position 1 = 32, Position 2 = 27
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
2 jumps found. (Code = 44) Position 1 = 32, Position 2 = 27
Branch analysis from position: 32
Branch analysis from position: 27
Branch analysis from position: 10
2 jumps found. (Code = 44) Position 1 = 15, Position 2 = 10
Branch analysis from position: 15
Branch analysis from position: 10
filename:       /in/3ulMW
function name:  (null)
number of ops:  38
compiled vars:  !0 = $test, !1 = $rounds, !2 = $start, !3 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   NEW                                              $4      'yii%5Cdb%5Ctest'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $4
   20     3        ASSIGN                                                   !1, 1000
   22     4        INIT_NS_FCALL_BY_NAME                                    'yii%5Cdb%5Cmicrotime'
          5        SEND_VAL_EX                                              <true>
          6        DO_FCALL                                      0  $8      
          7        ASSIGN                                                   !2, $8
   23     8        ASSIGN                                                   !3, 0
          9      > JMP                                                      ->13
   24    10    >   INIT_METHOD_CALL                                         !0, 'formName1'
         11        DO_FCALL                                      0          
   23    12        PRE_INC                                                  !3
         13    >   IS_SMALLER                                               !3, !1
         14      > JMPNZ                                                    ~13, ->10
   26    15    >   INIT_NS_FCALL_BY_NAME                                    'yii%5Cdb%5Cmicrotime'
         16        SEND_VAL_EX                                              <true>
         17        DO_FCALL                                      0  $14     
         18        SUB                                              ~15     $14, !2
         19        ECHO                                                     ~15
   28    20        ECHO                                                     '%0A'
   30    21        INIT_NS_FCALL_BY_NAME                                    'yii%5Cdb%5Cmicrotime'
         22        SEND_VAL_EX                                              <true>
         23        DO_FCALL                                      0  $16     
         24        ASSIGN                                                   !2, $16
   31    25        ASSIGN                                                   !3, 0
         26      > JMP                                                      ->30
   32    27    >   INIT_METHOD_CALL                                         !0, 'formName2'
         28        DO_FCALL                                      0          
   31    29        PRE_INC                                                  !3
         30    >   IS_SMALLER                                               !3, !1
         31      > JMPNZ                                                    ~21, ->27
   34    32    >   INIT_NS_FCALL_BY_NAME                                    'yii%5Cdb%5Cmicrotime'
         33        SEND_VAL_EX                                              <true>
         34        DO_FCALL                                      0  $22     
         35        SUB                                              ~23     $22, !2
         36        ECHO                                                     ~23
         37      > RETURN                                                   1

Class yii\db\test:
Function formname1:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 14
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3ulMW
function name:  formName1
number of ops:  22
compiled vars:  !0 = $class, !1 = $pos
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   INIT_NS_FCALL_BY_NAME                                    'yii%5Cdb%5Cget_class'
          1        FETCH_THIS                                       $2      
          2        SEND_VAR_EX                                              $2
          3        DO_FCALL                                      0  $3      
          4        ASSIGN                                                   !0, $3
    8     5        INIT_NS_FCALL_BY_NAME                                    'yii%5Cdb%5Cstrrpos'
          6        SEND_VAR_EX                                              !0
          7        SEND_VAL_EX                                              '%5C'
          8        DO_FCALL                                      0  $5      
          9        ASSIGN                                                   !1, $5
    9    10        TYPE_CHECK                                    4          !1
         11      > JMPZ                                                     ~7, ->14
         12    >   QM_ASSIGN                                        ~8      !0
         13      > JMP                                                      ->20
         14    >   INIT_NS_FCALL_BY_NAME                                    'yii%5Cdb%5Csubstr'
         15        SEND_VAR_EX                                              !0
         16        ADD                                              ~9      !1, 1
         17        SEND_VAL_EX                                              ~9
         18        DO_FCALL                                      0  $10     
         19        QM_ASSIGN                                        ~8      $10
         20    > > RETURN                                                   ~8
   10    21*     > RETURN                                                   null

End of function formname1

Function formname2:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3ulMW
function name:  formName2
number of ops:  9
compiled vars:  !0 = $reflector
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   NEW                                              $1      'ReflectionClass'
          1        FETCH_THIS                                       $2      
          2        SEND_VAR_EX                                              $2
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $1
   15     5        INIT_METHOD_CALL                                         !0, 'getShortName'
          6        DO_FCALL                                      0  $5      
          7      > RETURN                                                   $5
   16     8*     > RETURN                                                   null

End of function formname2

End of class yii\db\test.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
170.66 ms | 1392 KiB | 21 Q