3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace foo\bar\baz; class ClassA{ public function getClassExplode(){ $c = array_pop(explode('\\', get_class())); return $c; } public function getClassReflection(){ $c = (new \ReflectionClass($this))->getShortName(); return $c; } public function getClassBasename(){ $c = basename(str_replace('\\', '/', get_class())); return $c; } } $a = new ClassA(); $num = 1000; $rounds = 10; $res = array( "Reflection" => array(), "Basename" => array(), "Explode" => array(), ); for($r = 0; $r < $rounds; $r++){ $start = microtime(true); for($i = 0; $i < $num; $i++){ $a->getClassReflection(); } $end = microtime(true); $res["Reflection"][] = ($end-$start); $start = microtime(true); for($i = 0; $i < $num; $i++){ $a->getClassBasename(); } $end = microtime(true); $res["Basename"][] = ($end-$start); $start = microtime(true); for($i = 0; $i < $num; $i++){ $a->getClassExplode(); } $end = microtime(true); $res["Explode"][] = ($end-$start); } echo "Reflection: ".array_sum($res["Reflection"])/count($res["Reflection"])." s ".$a->getClassReflection()."\n"; echo "Basename: ".array_sum($res["Basename"])/count($res["Basename"])." s ".$a->getClassBasename()."\n"; echo "Explode: ".array_sum($res["Explode"])/count($res["Explode"])." s ".$a->getClassExplode()."\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 66
Branch analysis from position: 66
2 jumps found. (Code = 44) Position 1 = 68, Position 2 = 8
Branch analysis from position: 68
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
2 jumps found. (Code = 44) Position 1 = 19, Position 2 = 14
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 = 33
Branch analysis from position: 38
1 jumps found. (Code = 42) Position 1 = 55
Branch analysis from position: 55
2 jumps found. (Code = 44) Position 1 = 57, Position 2 = 52
Branch analysis from position: 57
2 jumps found. (Code = 44) Position 1 = 68, Position 2 = 8
Branch analysis from position: 68
Branch analysis from position: 8
Branch analysis from position: 52
2 jumps found. (Code = 44) Position 1 = 57, Position 2 = 52
Branch analysis from position: 57
Branch analysis from position: 52
Branch analysis from position: 33
2 jumps found. (Code = 44) Position 1 = 38, Position 2 = 33
Branch analysis from position: 38
Branch analysis from position: 33
Branch analysis from position: 14
2 jumps found. (Code = 44) Position 1 = 19, Position 2 = 14
Branch analysis from position: 19
Branch analysis from position: 14
filename:       /in/QB2LL
function name:  (null)
number of ops:  123
compiled vars:  !0 = $a, !1 = $num, !2 = $rounds, !3 = $res, !4 = $r, !5 = $start, !6 = $i, !7 = $end
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   NEW                                              $8      'foo%5Cbar%5Cbaz%5CClassA'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $8
   23     3        ASSIGN                                                   !1, 1000
   25     4        ASSIGN                                                   !2, 10
   26     5        ASSIGN                                                   !3, <array>
   32     6        ASSIGN                                                   !4, 0
          7      > JMP                                                      ->66
   34     8    >   INIT_NS_FCALL_BY_NAME                                    'foo%5Cbar%5Cbaz%5Cmicrotime'
          9        SEND_VAL_EX                                              <true>
         10        DO_FCALL                                      0  $15     
         11        ASSIGN                                                   !5, $15
   35    12        ASSIGN                                                   !6, 0
         13      > JMP                                                      ->17
   36    14    >   INIT_METHOD_CALL                                         !0, 'getClassReflection'
         15        DO_FCALL                                      0          
   35    16        PRE_INC                                                  !6
         17    >   IS_SMALLER                                               !6, !1
         18      > JMPNZ                                                    ~20, ->14
   38    19    >   INIT_NS_FCALL_BY_NAME                                    'foo%5Cbar%5Cbaz%5Cmicrotime'
         20        SEND_VAL_EX                                              <true>
         21        DO_FCALL                                      0  $21     
         22        ASSIGN                                                   !7, $21
   39    23        SUB                                              ~25     !7, !5
         24        FETCH_DIM_W                                      $23     !3, 'Reflection'
         25        ASSIGN_DIM                                               $23
         26        OP_DATA                                                  ~25
   41    27        INIT_NS_FCALL_BY_NAME                                    'foo%5Cbar%5Cbaz%5Cmicrotime'
         28        SEND_VAL_EX                                              <true>
         29        DO_FCALL                                      0  $26     
         30        ASSIGN                                                   !5, $26
   42    31        ASSIGN                                                   !6, 0
         32      > JMP                                                      ->36
   43    33    >   INIT_METHOD_CALL                                         !0, 'getClassBasename'
         34        DO_FCALL                                      0          
   42    35        PRE_INC                                                  !6
         36    >   IS_SMALLER                                               !6, !1
         37      > JMPNZ                                                    ~31, ->33
   45    38    >   INIT_NS_FCALL_BY_NAME                                    'foo%5Cbar%5Cbaz%5Cmicrotime'
         39        SEND_VAL_EX                                              <true>
         40        DO_FCALL                                      0  $32     
         41        ASSIGN                                                   !7, $32
   46    42        SUB                                              ~36     !7, !5
         43        FETCH_DIM_W                                      $34     !3, 'Basename'
         44        ASSIGN_DIM                                               $34
         45        OP_DATA                                                  ~36
   48    46        INIT_NS_FCALL_BY_NAME                                    'foo%5Cbar%5Cbaz%5Cmicrotime'
         47        SEND_VAL_EX                                              <true>
         48        DO_FCALL                                      0  $37     
         49        ASSIGN                                                   !5, $37
   49    50        ASSIGN                                                   !6, 0
         51      > JMP                                                      ->55
   50    52    >   INIT_METHOD_CALL                                         !0, 'getClassExplode'
         53        DO_FCALL                                      0          
   49    54        PRE_INC                                                  !6
         55    >   IS_SMALLER                                               !6, !1
         56      > JMPNZ                                                    ~42, ->52
   52    57    >   INIT_NS_FCALL_BY_NAME                                    'foo%5Cbar%5Cbaz%5Cmicrotime'
         58        SEND_VAL_EX                                              <true>
         59        DO_FCALL                                      0  $43     
         60        ASSIGN                                                   !7, $43
   53    61        SUB                                              ~47     !7, !5
         62        FETCH_DIM_W                                      $45     !3, 'Explode'
         63        ASSIGN_DIM                                               $45
         64        OP_DATA                                                  ~47
   32    65        PRE_INC                                                  !4
         66    >   IS_SMALLER                                               !4, !2
         67      > JMPNZ                                                    ~49, ->8
   56    68    >   INIT_NS_FCALL_BY_NAME                                    'foo%5Cbar%5Cbaz%5Carray_sum'
         69        CHECK_FUNC_ARG                                           
         70        FETCH_DIM_FUNC_ARG                               $50     !3, 'Reflection'
         71        SEND_FUNC_ARG                                            $50
         72        DO_FCALL                                      0  $51     
         73        INIT_NS_FCALL_BY_NAME                                    'foo%5Cbar%5Cbaz%5Ccount'
         74        CHECK_FUNC_ARG                                           
         75        FETCH_DIM_FUNC_ARG                               $52     !3, 'Reflection'
         76        SEND_FUNC_ARG                                            $52
         77        DO_FCALL                                      0  $53     
         78        DIV                                              ~54     $51, $53
         79        CONCAT                                           ~55     'Reflection%3A+', ~54
         80        CONCAT                                           ~56     ~55, '+s+'
         81        INIT_METHOD_CALL                                         !0, 'getClassReflection'
         82        DO_FCALL                                      0  $57     
         83        CONCAT                                           ~58     ~56, $57
         84        CONCAT                                           ~59     ~58, '%0A'
         85        ECHO                                                     ~59
   57    86        INIT_NS_FCALL_BY_NAME                                    'foo%5Cbar%5Cbaz%5Carray_sum'
         87        CHECK_FUNC_ARG                                           
         88        FETCH_DIM_FUNC_ARG                               $60     !3, 'Basename'
         89        SEND_FUNC_ARG                                            $60
         90        DO_FCALL                                      0  $61     
         91        INIT_NS_FCALL_BY_NAME                                    'foo%5Cbar%5Cbaz%5Ccount'
         92        CHECK_FUNC_ARG                                           
         93        FETCH_DIM_FUNC_ARG                               $62     !3, 'Basename'
         94        SEND_FUNC_ARG                                            $62
         95        DO_FCALL                                      0  $63     
         96        DIV                                              ~64     $61, $63
         97        CONCAT                                           ~65     'Basename%3A+', ~64
         98        CONCAT                                           ~66     ~65, '+s+'
         99        INIT_METHOD_CALL                                         !0, 'getClassBasename'
        100        DO_FCALL                                      0  $67     
        101        CONCAT                                           ~68     ~66, $67
        102        CONCAT                                           ~69     ~68, '%0A'
        103        ECHO                                                     ~69
   58   104        INIT_NS_FCALL_BY_NAME                                    'foo%5Cbar%5Cbaz%5Carray_sum'
        105        CHECK_FUNC_ARG                                           
        106        FETCH_DIM_FUNC_ARG                               $70     !3, 'Explode'
        107        SEND_FUNC_ARG                                            $70
        108        DO_FCALL                                      0  $71     
        109        INIT_NS_FCALL_BY_NAME                                    'foo%5Cbar%5Cbaz%5Ccount'
        110        CHECK_FUNC_ARG                                           
        111        FETCH_DIM_FUNC_ARG                               $72     !3, 'Explode'
        112        SEND_FUNC_ARG                                            $72
        113        DO_FCALL                                      0  $73     
        114        DIV                                              ~74     $71, $73
        115        CONCAT                                           ~75     'Explode%3A+', ~74
        116        CONCAT                                           ~76     ~75, '+s+'
        117        INIT_METHOD_CALL                                         !0, 'getClassExplode'
        118        DO_FCALL                                      0  $77     
        119        CONCAT                                           ~78     ~76, $77
        120        CONCAT                                           ~79     ~78, '%0A'
        121        ECHO                                                     ~79
        122      > RETURN                                                   1

Class foo\bar\baz\ClassA:
Function getclassexplode:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/QB2LL
function name:  getClassExplode
number of ops:  12
compiled vars:  !0 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   INIT_NS_FCALL_BY_NAME                                    'foo%5Cbar%5Cbaz%5Carray_pop'
          1        INIT_NS_FCALL_BY_NAME                                    'foo%5Cbar%5Cbaz%5Cexplode'
          2        SEND_VAL_EX                                              '%5C'
          3        INIT_NS_FCALL_BY_NAME                                    'foo%5Cbar%5Cbaz%5Cget_class'
          4        DO_FCALL                                      0  $1      
          5        SEND_VAR_NO_REF_EX                                       $1
          6        DO_FCALL                                      0  $2      
          7        SEND_VAR_NO_REF_EX                                       $2
          8        DO_FCALL                                      0  $3      
          9        ASSIGN                                                   !0, $3
    8    10      > RETURN                                                   !0
    9    11*     > RETURN                                                   null

End of function getclassexplode

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

End of function getclassreflection

Function getclassbasename:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/QB2LL
function name:  getClassBasename
number of ops:  13
compiled vars:  !0 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   INIT_NS_FCALL_BY_NAME                                    'foo%5Cbar%5Cbaz%5Cbasename'
          1        INIT_NS_FCALL_BY_NAME                                    'foo%5Cbar%5Cbaz%5Cstr_replace'
          2        SEND_VAL_EX                                              '%5C'
          3        SEND_VAL_EX                                              '%2F'
          4        INIT_NS_FCALL_BY_NAME                                    'foo%5Cbar%5Cbaz%5Cget_class'
          5        DO_FCALL                                      0  $1      
          6        SEND_VAR_NO_REF_EX                                       $1
          7        DO_FCALL                                      0  $2      
          8        SEND_VAR_NO_REF_EX                                       $2
          9        DO_FCALL                                      0  $3      
         10        ASSIGN                                                   !0, $3
   18    11      > RETURN                                                   !0
   19    12*     > RETURN                                                   null

End of function getclassbasename

End of class foo\bar\baz\ClassA.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.37 ms | 1412 KiB | 29 Q