3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private $spec; private $msg; public function __construct($spec, $msg = null) { $this->spec = $spec; $this->msg = $msg; } public static function new_instance($spec, $msg = null) { return new static($spec, $msg); } } const ITERATIONS = 1000000; $time1 = -microtime(true); for ($i = 0; $i < ITERATIONS; ++$i) { Foo::new_instance([], 'foo'); } $time1 += microtime(true); echo "direct function call took $time1 seconds\n"; $time2 = -microtime(true); for ($i = 0; $i < ITERATIONS; ++$i) { call_user_func_array(['Foo', 'new_instance'], [[], 'foo']); } $time2 += microtime(true); echo "call_user_func_array() took $time2 seconds\n"; echo "difference: ", $time2 / $time1, "\n";
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 = 16, Position 2 = 8
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 36
Branch analysis from position: 36
2 jumps found. (Code = 44) Position 1 = 39, Position 2 = 31
Branch analysis from position: 39
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
2 jumps found. (Code = 44) Position 1 = 39, Position 2 = 31
Branch analysis from position: 39
Branch analysis from position: 31
Branch analysis from position: 8
2 jumps found. (Code = 44) Position 1 = 16, Position 2 = 8
Branch analysis from position: 16
Branch analysis from position: 8
filename:       /in/41b8T
function name:  (null)
number of ops:  52
compiled vars:  !0 = $time1, !1 = $i, !2 = $time2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   DECLARE_CONST                                            'ITERATIONS', 1000000
   19     1        INIT_FCALL                                               'microtime'
          2        SEND_VAL                                                 <true>
          3        DO_ICALL                                         $3      
          4        MUL                                              ~4      $3, -1
          5        ASSIGN                                                   !0, ~4
   20     6        ASSIGN                                                   !1, 0
          7      > JMP                                                      ->13
   21     8    >   INIT_STATIC_METHOD_CALL                                  'Foo', 'new_instance'
          9        SEND_VAL                                                 <array>
         10        SEND_VAL                                                 'foo'
         11        DO_FCALL                                      0          
   20    12        PRE_INC                                                  !1
         13    >   FETCH_CONSTANT                                   ~9      'ITERATIONS'
         14        IS_SMALLER                                               !1, ~9
         15      > JMPNZ                                                    ~10, ->8
   23    16    >   INIT_FCALL                                               'microtime'
         17        SEND_VAL                                                 <true>
         18        DO_ICALL                                         $11     
         19        ASSIGN_OP                                     1          !0, $11
   24    20        ROPE_INIT                                     3  ~14     'direct+function+call+++took+'
         21        ROPE_ADD                                      1  ~14     ~14, !0
         22        ROPE_END                                      2  ~13     ~14, '+seconds%0A'
         23        ECHO                                                     ~13
   27    24        INIT_FCALL                                               'microtime'
         25        SEND_VAL                                                 <true>
         26        DO_ICALL                                         $16     
         27        MUL                                              ~17     $16, -1
         28        ASSIGN                                                   !2, ~17
   28    29        ASSIGN                                                   !1, 0
         30      > JMP                                                      ->36
   29    31    >   INIT_USER_CALL                                0          'call_user_func_array', <array>
         32        SEND_ARRAY                                               <array>
         33        CHECK_UNDEF_ARGS                                         
         34        DO_FCALL                                      0          
   28    35        PRE_INC                                                  !1
         36    >   FETCH_CONSTANT                                   ~22     'ITERATIONS'
         37        IS_SMALLER                                               !1, ~22
         38      > JMPNZ                                                    ~23, ->31
   31    39    >   INIT_FCALL                                               'microtime'
         40        SEND_VAL                                                 <true>
         41        DO_ICALL                                         $24     
         42        ASSIGN_OP                                     1          !2, $24
   32    43        ROPE_INIT                                     3  ~27     'call_user_func_array%28%29+took+'
         44        ROPE_ADD                                      1  ~27     ~27, !2
         45        ROPE_END                                      2  ~26     ~27, '+seconds%0A'
         46        ECHO                                                     ~26
   34    47        ECHO                                                     'difference%3A+'
         48        DIV                                              ~29     !2, !0
         49        ECHO                                                     ~29
         50        ECHO                                                     '%0A'
         51      > RETURN                                                   1

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

End of function __construct

Function new_instance:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/41b8T
function name:  new_instance
number of ops:  8
compiled vars:  !0 = $spec, !1 = $msg
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      null
   13     2        NEW                          static              $2      
          3        SEND_VAR_EX                                              !0
          4        SEND_VAR_EX                                              !1
          5        DO_FCALL                                      0          
          6      > RETURN                                                   $2
   14     7*     > RETURN                                                   null

End of function new_instance

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.91 ms | 1400 KiB | 15 Q