3v4l.org

run code in 300+ PHP versions simultaneously
<?php function test() {} $nIter = 10000; $argNums = array(0, 1, 2, 3, 4, 5); $func = 'test'; foreach ($argNums as $argNum) { $args = $argNum == 0 ? [] : array_fill(0, $argNum, null); $startTime = microtime(true); for ($i = 0; $i < $nIter; ++$i) { call_user_func_array($func, $args); } $endTime = microtime(true); echo "cufa with $argNum args took ", $endTime - $startTime, "\n"; $startTime = microtime(true); for ($i = 0; $i < $nIter; ++$i) { switch (count($args)) { case 0: $func(); break; case 1: $func($args[0]); break; case 2: $func($args[0], $args[1]); break; case 3: $func($args[0], $args[1], $args[2]); break; case 4: $func($args[0], $args[1], $args[2], $args[3]); break; case 5: $func($args[0], $args[1], $args[2], $args[3], $args[4]); break; default: call_user_func_array($func, $args); break; } } $endTime = microtime(true); echo "switch with $argNum args took ", $endTime - $startTime, "\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 145
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 145
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 9
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 22
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 131
Branch analysis from position: 131
2 jumps found. (Code = 44) Position 1 = 133, Position 2 = 46
Branch analysis from position: 133
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 46
8 jumps found. (Code = 187) Position 1 = 61, Position 2 = 64, Position 3 = 70, Position 4 = 79, Position 5 = 91, Position 6 = 106, Position 7 = 124, Position 8 = 48
Branch analysis from position: 61
1 jumps found. (Code = 42) Position 1 = 129
Branch analysis from position: 129
2 jumps found. (Code = 44) Position 1 = 133, Position 2 = 46
Branch analysis from position: 133
Branch analysis from position: 46
Branch analysis from position: 64
1 jumps found. (Code = 42) Position 1 = 129
Branch analysis from position: 129
Branch analysis from position: 70
1 jumps found. (Code = 42) Position 1 = 129
Branch analysis from position: 129
Branch analysis from position: 79
1 jumps found. (Code = 42) Position 1 = 129
Branch analysis from position: 129
Branch analysis from position: 91
1 jumps found. (Code = 42) Position 1 = 129
Branch analysis from position: 129
Branch analysis from position: 106
1 jumps found. (Code = 42) Position 1 = 129
Branch analysis from position: 129
Branch analysis from position: 124
1 jumps found. (Code = 42) Position 1 = 129
Branch analysis from position: 129
Branch analysis from position: 48
2 jumps found. (Code = 44) Position 1 = 50, Position 2 = 61
Branch analysis from position: 50
2 jumps found. (Code = 44) Position 1 = 52, Position 2 = 64
Branch analysis from position: 52
2 jumps found. (Code = 44) Position 1 = 54, Position 2 = 70
Branch analysis from position: 54
2 jumps found. (Code = 44) Position 1 = 56, Position 2 = 79
Branch analysis from position: 56
2 jumps found. (Code = 44) Position 1 = 58, Position 2 = 91
Branch analysis from position: 58
2 jumps found. (Code = 44) Position 1 = 60, Position 2 = 106
Branch analysis from position: 60
1 jumps found. (Code = 42) Position 1 = 124
Branch analysis from position: 124
Branch analysis from position: 106
Branch analysis from position: 91
Branch analysis from position: 79
Branch analysis from position: 70
Branch analysis from position: 64
Branch analysis from position: 61
Branch analysis from position: 22
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 22
Branch analysis from position: 29
Branch analysis from position: 22
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
Branch analysis from position: 145
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 145
filename:       /in/27UIv
function name:  (null)
number of ops:  147
compiled vars:  !0 = $nIter, !1 = $argNums, !2 = $func, !3 = $argNum, !4 = $args, !5 = $startTime, !6 = $i, !7 = $endTime
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   ASSIGN                                                   !0, 10000
    7     1        ASSIGN                                                   !1, <array>
    9     2        ASSIGN                                                   !2, 'test'
   11     3      > FE_RESET_R                                       $11     !1, ->145
          4    > > FE_FETCH_R                                               $11, !3, ->145
   12     5    >   IS_EQUAL                                                 !3, 0
          6      > JMPZ                                                     ~12, ->9
          7    >   QM_ASSIGN                                        ~13     <array>
          8      > JMP                                                      ->15
          9    >   INIT_FCALL                                               'array_fill'
         10        SEND_VAL                                                 0
         11        SEND_VAR                                                 !3
         12        SEND_VAL                                                 null
         13        DO_ICALL                                         $14     
         14        QM_ASSIGN                                        ~13     $14
         15    >   ASSIGN                                                   !4, ~13
   14    16        INIT_FCALL                                               'microtime'
         17        SEND_VAL                                                 <true>
         18        DO_ICALL                                         $16     
         19        ASSIGN                                                   !5, $16
   15    20        ASSIGN                                                   !6, 0
         21      > JMP                                                      ->27
   16    22    >   INIT_USER_CALL                                0          'call_user_func_array', !2
         23        SEND_ARRAY                                               !4
         24        CHECK_UNDEF_ARGS                                         
         25        DO_FCALL                                      0          
   15    26        PRE_INC                                                  !6
         27    >   IS_SMALLER                                               !6, !0
         28      > JMPNZ                                                    ~21, ->22
   18    29    >   INIT_FCALL                                               'microtime'
         30        SEND_VAL                                                 <true>
         31        DO_ICALL                                         $22     
         32        ASSIGN                                                   !7, $22
   19    33        ROPE_INIT                                     3  ~25     'cufa+++with+'
         34        ROPE_ADD                                      1  ~25     ~25, !3
         35        ROPE_END                                      2  ~24     ~25, '+args+took+'
         36        ECHO                                                     ~24
         37        SUB                                              ~27     !7, !5
         38        ECHO                                                     ~27
         39        ECHO                                                     '%0A'
   21    40        INIT_FCALL                                               'microtime'
         41        SEND_VAL                                                 <true>
         42        DO_ICALL                                         $28     
         43        ASSIGN                                                   !5, $28
   22    44        ASSIGN                                                   !6, 0
         45      > JMP                                                      ->131
   23    46    >   COUNT                                            ~31     !4
         47      > SWITCH_LONG                                              ~31, [ 0:->61, 1:->64, 2:->70, 3:->79, 4:->91, 5:->106, ], ->124
   24    48    >   CASE                                                     ~31, 0
         49      > JMPNZ                                                    ~32, ->61
   25    50    >   CASE                                                     ~31, 1
         51      > JMPNZ                                                    ~32, ->64
   26    52    >   CASE                                                     ~31, 2
         53      > JMPNZ                                                    ~32, ->70
   27    54    >   CASE                                                     ~31, 3
         55      > JMPNZ                                                    ~32, ->79
   28    56    >   CASE                                                     ~31, 4
         57      > JMPNZ                                                    ~32, ->91
   29    58    >   CASE                                                     ~31, 5
         59      > JMPNZ                                                    ~32, ->106
         60    > > JMP                                                      ->124
   24    61    >   INIT_DYNAMIC_CALL                                        !2
         62        DO_FCALL                                      0          
         63      > JMP                                                      ->129
   25    64    >   INIT_DYNAMIC_CALL                                        !2
         65        CHECK_FUNC_ARG                                           
         66        FETCH_DIM_FUNC_ARG                               $34     !4, 0
         67        SEND_FUNC_ARG                                            $34
         68        DO_FCALL                                      0          
         69      > JMP                                                      ->129
   26    70    >   INIT_DYNAMIC_CALL                                        !2
         71        CHECK_FUNC_ARG                                           
         72        FETCH_DIM_FUNC_ARG                               $36     !4, 0
         73        SEND_FUNC_ARG                                            $36
         74        CHECK_FUNC_ARG                                           
         75        FETCH_DIM_FUNC_ARG                               $37     !4, 1
         76        SEND_FUNC_ARG                                            $37
         77        DO_FCALL                                      0          
         78      > JMP                                                      ->129
   27    79    >   INIT_DYNAMIC_CALL                                        !2
         80        CHECK_FUNC_ARG                                           
         81        FETCH_DIM_FUNC_ARG                               $39     !4, 0
         82        SEND_FUNC_ARG                                            $39
         83        CHECK_FUNC_ARG                                           
         84        FETCH_DIM_FUNC_ARG                               $40     !4, 1
         85        SEND_FUNC_ARG                                            $40
         86        CHECK_FUNC_ARG                                           
         87        FETCH_DIM_FUNC_ARG                               $41     !4, 2
         88        SEND_FUNC_ARG                                            $41
         89        DO_FCALL                                      0          
         90      > JMP                                                      ->129
   28    91    >   INIT_DYNAMIC_CALL                                        !2
         92        CHECK_FUNC_ARG                                           
         93        FETCH_DIM_FUNC_ARG                               $43     !4, 0
         94        SEND_FUNC_ARG                                            $43
         95        CHECK_FUNC_ARG                                           
         96        FETCH_DIM_FUNC_ARG                               $44     !4, 1
         97        SEND_FUNC_ARG                                            $44
         98        CHECK_FUNC_ARG                                           
         99        FETCH_DIM_FUNC_ARG                               $45     !4, 2
        100        SEND_FUNC_ARG                                            $45
        101        CHECK_FUNC_ARG                                           
        102        FETCH_DIM_FUNC_ARG                               $46     !4, 3
        103        SEND_FUNC_ARG                                            $46
        104        DO_FCALL                                      0          
        105      > JMP                                                      ->129
   29   106    >   INIT_DYNAMIC_CALL                                        !2
        107        CHECK_FUNC_ARG                                           
        108        FETCH_DIM_FUNC_ARG                               $48     !4, 0
        109        SEND_FUNC_ARG                                            $48
        110        CHECK_FUNC_ARG                                           
        111        FETCH_DIM_FUNC_ARG                               $49     !4, 1
        112        SEND_FUNC_ARG                                            $49
        113        CHECK_FUNC_ARG                                           
        114        FETCH_DIM_FUNC_ARG                               $50     !4, 2
        115        SEND_FUNC_ARG                                            $50
        116        CHECK_FUNC_ARG                                           
        117        FETCH_DIM_FUNC_ARG                               $51     !4, 3
        118        SEND_FUNC_ARG                                            $51
        119        CHECK_FUNC_ARG                                           
        120        FETCH_DIM_FUNC_ARG                               $52     !4, 4
        121        SEND_FUNC_ARG                                            $52
        122        DO_FCALL                                      0          
        123      > JMP                                                      ->129
   30   124    >   INIT_USER_CALL                                0          'call_user_func_array', !2
        125        SEND_ARRAY                                               !4
        126        CHECK_UNDEF_ARGS                                         
        127        DO_FCALL                                      0          
        128      > JMP                                                      ->129
        129    >   FREE                                                     ~31
   22   130        PRE_INC                                                  !6
        131    >   IS_SMALLER                                               !6, !0
        132      > JMPNZ                                                    ~56, ->46
   33   133    >   INIT_FCALL                                               'microtime'
        134        SEND_VAL                                                 <true>
        135        DO_ICALL                                         $57     
        136        ASSIGN                                                   !7, $57
   34   137        ROPE_INIT                                     3  ~60     'switch+with+'
        138        ROPE_ADD                                      1  ~60     ~60, !3
        139        ROPE_END                                      2  ~59     ~60, '+args+took+'
        140        ECHO                                                     ~59
        141        SUB                                              ~62     !7, !5
        142        ECHO                                                     ~62
        143        ECHO                                                     '%0A'
   11   144      > JMP                                                      ->4
        145    >   FE_FREE                                                  $11
   36   146      > RETURN                                                   1

Function test:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/27UIv
function name:  test
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E > > RETURN                                                   null

End of function test

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.32 ms | 1408 KiB | 17 Q