3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Test { private $args = array(1,2,3); public function foo() { $closureToCall = 'max'; //this function accepts multiple args $start = microtime(true); for ($i=0; $i<1e5; $i++) { $args = $this->arguments; switch (count($args)) { case 0: $closureToCall(); case 1: $closureToCall($args[0]); case 2: $closureToCall($args[0], $args[1]); case 3: $closureToCall($args[0], $args[1], $args[2]); case 4: $closureToCall($args[0], $args[1], $args[2], $args[3]); case 5: $closureToCall($args[0], $args[1], $args[2], $args[3], $args[4]); default: forward_static_call_array($closureToCall, $args); } } $end = microtime(true); echo "Took: ", ($end-$start)*1e3, " ms"; $start = microtime(true); for ($i=0; $i<1e5; $i++) { $args = $this->arguments; $closureToCall(...$args); } $end = microtime(true); echo "Took: ", ($end-$start)*1e3, " ms"; } } $obj = new Test; $obj->foo();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fqbb0
function name:  (null)
number of ops:  6
compiled vars:  !0 = $obj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   42     0  E >   NEW                                              $1      'Test'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   43     3        INIT_METHOD_CALL                                         !0, 'foo'
          4        DO_FCALL                                      0          
          5      > RETURN                                                   1

Class Test:
Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 87
Branch analysis from position: 87
2 jumps found. (Code = 44) Position 1 = 89, Position 2 = 7
Branch analysis from position: 89
1 jumps found. (Code = 42) Position 1 = 111
Branch analysis from position: 111
2 jumps found. (Code = 44) Position 1 = 113, Position 2 = 104
Branch analysis from position: 113
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 104
2 jumps found. (Code = 44) Position 1 = 113, Position 2 = 104
Branch analysis from position: 113
Branch analysis from position: 104
Branch analysis from position: 7
8 jumps found. (Code = 187) Position 1 = 24, Position 2 = 26, Position 3 = 31, Position 4 = 39, Position 5 = 50, Position 6 = 64, Position 7 = 81, Position 8 = 11
Branch analysis from position: 24
2 jumps found. (Code = 44) Position 1 = 89, Position 2 = 7
Branch analysis from position: 89
Branch analysis from position: 7
Branch analysis from position: 26
Branch analysis from position: 31
Branch analysis from position: 39
Branch analysis from position: 50
Branch analysis from position: 64
Branch analysis from position: 81
Branch analysis from position: 11
2 jumps found. (Code = 44) Position 1 = 13, Position 2 = 24
Branch analysis from position: 13
2 jumps found. (Code = 44) Position 1 = 15, Position 2 = 26
Branch analysis from position: 15
2 jumps found. (Code = 44) Position 1 = 17, Position 2 = 31
Branch analysis from position: 17
2 jumps found. (Code = 44) Position 1 = 19, Position 2 = 39
Branch analysis from position: 19
2 jumps found. (Code = 44) Position 1 = 21, Position 2 = 50
Branch analysis from position: 21
2 jumps found. (Code = 44) Position 1 = 23, Position 2 = 64
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 81
Branch analysis from position: 81
Branch analysis from position: 64
Branch analysis from position: 50
Branch analysis from position: 39
Branch analysis from position: 31
Branch analysis from position: 26
Branch analysis from position: 24
filename:       /in/fqbb0
function name:  foo
number of ops:  123
compiled vars:  !0 = $closureToCall, !1 = $start, !2 = $i, !3 = $args, !4 = $end
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   ASSIGN                                                   !0, 'max'
    9     1        INIT_FCALL                                               'microtime'
          2        SEND_VAL                                                 <true>
          3        DO_ICALL                                         $6      
          4        ASSIGN                                                   !1, $6
   10     5        ASSIGN                                                   !2, 0
          6      > JMP                                                      ->87
   11     7    >   FETCH_OBJ_R                                      ~9      'arguments'
          8        ASSIGN                                                   !3, ~9
   13     9        COUNT                                            ~11     !3
         10      > SWITCH_LONG                                              ~11, [ 0:->24, 1:->26, 2:->31, 3:->39, 4:->50, 5:->64, ], ->81
   14    11    >   CASE                                                     ~11, 0
         12      > JMPNZ                                                    ~12, ->24
   16    13    >   CASE                                                     ~11, 1
         14      > JMPNZ                                                    ~12, ->26
   18    15    >   CASE                                                     ~11, 2
         16      > JMPNZ                                                    ~12, ->31
   20    17    >   CASE                                                     ~11, 3
         18      > JMPNZ                                                    ~12, ->39
   22    19    >   CASE                                                     ~11, 4
         20      > JMPNZ                                                    ~12, ->50
   24    21    >   CASE                                                     ~11, 5
         22      > JMPNZ                                                    ~12, ->64
         23    > > JMP                                                      ->81
   15    24    >   INIT_DYNAMIC_CALL                                        !0
         25        DO_FCALL                                      0          
   17    26    >   INIT_DYNAMIC_CALL                                        !0
         27        CHECK_FUNC_ARG                                           
         28        FETCH_DIM_FUNC_ARG                               $14     !3, 0
         29        SEND_FUNC_ARG                                            $14
         30        DO_FCALL                                      0          
   19    31    >   INIT_DYNAMIC_CALL                                        !0
         32        CHECK_FUNC_ARG                                           
         33        FETCH_DIM_FUNC_ARG                               $16     !3, 0
         34        SEND_FUNC_ARG                                            $16
         35        CHECK_FUNC_ARG                                           
         36        FETCH_DIM_FUNC_ARG                               $17     !3, 1
         37        SEND_FUNC_ARG                                            $17
         38        DO_FCALL                                      0          
   21    39    >   INIT_DYNAMIC_CALL                                        !0
         40        CHECK_FUNC_ARG                                           
         41        FETCH_DIM_FUNC_ARG                               $19     !3, 0
         42        SEND_FUNC_ARG                                            $19
         43        CHECK_FUNC_ARG                                           
         44        FETCH_DIM_FUNC_ARG                               $20     !3, 1
         45        SEND_FUNC_ARG                                            $20
         46        CHECK_FUNC_ARG                                           
         47        FETCH_DIM_FUNC_ARG                               $21     !3, 2
         48        SEND_FUNC_ARG                                            $21
         49        DO_FCALL                                      0          
   23    50    >   INIT_DYNAMIC_CALL                                        !0
         51        CHECK_FUNC_ARG                                           
         52        FETCH_DIM_FUNC_ARG                               $23     !3, 0
         53        SEND_FUNC_ARG                                            $23
         54        CHECK_FUNC_ARG                                           
         55        FETCH_DIM_FUNC_ARG                               $24     !3, 1
         56        SEND_FUNC_ARG                                            $24
         57        CHECK_FUNC_ARG                                           
         58        FETCH_DIM_FUNC_ARG                               $25     !3, 2
         59        SEND_FUNC_ARG                                            $25
         60        CHECK_FUNC_ARG                                           
         61        FETCH_DIM_FUNC_ARG                               $26     !3, 3
         62        SEND_FUNC_ARG                                            $26
         63        DO_FCALL                                      0          
   25    64    >   INIT_DYNAMIC_CALL                                        !0
         65        CHECK_FUNC_ARG                                           
         66        FETCH_DIM_FUNC_ARG                               $28     !3, 0
         67        SEND_FUNC_ARG                                            $28
         68        CHECK_FUNC_ARG                                           
         69        FETCH_DIM_FUNC_ARG                               $29     !3, 1
         70        SEND_FUNC_ARG                                            $29
         71        CHECK_FUNC_ARG                                           
         72        FETCH_DIM_FUNC_ARG                               $30     !3, 2
         73        SEND_FUNC_ARG                                            $30
         74        CHECK_FUNC_ARG                                           
         75        FETCH_DIM_FUNC_ARG                               $31     !3, 3
         76        SEND_FUNC_ARG                                            $31
         77        CHECK_FUNC_ARG                                           
         78        FETCH_DIM_FUNC_ARG                               $32     !3, 4
         79        SEND_FUNC_ARG                                            $32
         80        DO_FCALL                                      0          
   27    81    >   INIT_FCALL                                               'forward_static_call_array'
         82        SEND_VAR                                                 !0
         83        SEND_VAR                                                 !3
         84        DO_ICALL                                                 
         85        FREE                                                     ~11
   10    86        PRE_INC                                                  !2
         87    >   IS_SMALLER                                               !2, 100000
         88      > JMPNZ                                                    ~36, ->7
   30    89    >   INIT_FCALL                                               'microtime'
         90        SEND_VAL                                                 <true>
         91        DO_ICALL                                         $37     
         92        ASSIGN                                                   !4, $37
   31    93        ECHO                                                     'Took%3A+'
         94        SUB                                              ~39     !4, !1
         95        MUL                                              ~40     ~39, 1000
         96        ECHO                                                     ~40
         97        ECHO                                                     '+ms'
   32    98        INIT_FCALL                                               'microtime'
         99        SEND_VAL                                                 <true>
        100        DO_ICALL                                         $41     
        101        ASSIGN                                                   !1, $41
   33   102        ASSIGN                                                   !2, 0
        103      > JMP                                                      ->111
   34   104    >   FETCH_OBJ_R                                      ~44     'arguments'
        105        ASSIGN                                                   !3, ~44
   35   106        INIT_DYNAMIC_CALL                                        !0
        107        SEND_UNPACK                                              !3
        108        CHECK_UNDEF_ARGS                                         
        109        DO_FCALL                                      1          
   33   110        PRE_INC                                                  !2
        111    >   IS_SMALLER                                               !2, 100000
        112      > JMPNZ                                                    ~48, ->104
   37   113    >   INIT_FCALL                                               'microtime'
        114        SEND_VAL                                                 <true>
        115        DO_ICALL                                         $49     
        116        ASSIGN                                                   !4, $49
   38   117        ECHO                                                     'Took%3A+'
        118        SUB                                              ~51     !4, !1
        119        MUL                                              ~52     ~51, 1000
        120        ECHO                                                     ~52
        121        ECHO                                                     '+ms'
   39   122      > RETURN                                                   null

End of function foo

End of class Test.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.6 ms | 1408 KiB | 17 Q