3v4l.org

run code in 300+ PHP versions simultaneously
<?php class IndexRange { /** @var 0|positive-int */ public int $start; /** @var 0|positive-int */ public int $end; /** * @param 0|positive-int $start * @param 0|positive-int $end */ public function __construct(int $start = null, int $end = null) { if (null !== $start) { $this->start = $start; } if (null !== $end) { $this->end = $end; } } } function acceptOne($a) {}; function acceptTwo($a, $b) {}; $t = microtime(true); for ($i = 0; $i < 100_000; $i++) { $start = $i; $end = $i; acceptTwo($start, $end); } echo '2 vars: ' . round((microtime(true) - $t) * 1000, 2) . " ms\n"; $t = microtime(true); for ($i = 0; $i < 100_000; $i++) { $rangeArr = [$i, $i]; acceptOne($rangeArr); } echo 'range arr: ' . round((microtime(true) - $t) * 1000, 2) . " ms\n"; $t = microtime(true); for ($i = 0; $i < 100_000; $i++) { $rangeObj = new IndexRange($i, $i); acceptOne($rangeObj); } echo 'range obj: ' . round((microtime(true) - $t) * 1000, 2) . " ms\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 = 15, Position 2 = 6
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
2 jumps found. (Code = 44) Position 1 = 42, Position 2 = 33
Branch analysis from position: 42
1 jumps found. (Code = 42) Position 1 = 69
Branch analysis from position: 69
2 jumps found. (Code = 44) Position 1 = 71, Position 2 = 60
Branch analysis from position: 71
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 60
2 jumps found. (Code = 44) Position 1 = 71, Position 2 = 60
Branch analysis from position: 71
Branch analysis from position: 60
Branch analysis from position: 33
2 jumps found. (Code = 44) Position 1 = 42, Position 2 = 33
Branch analysis from position: 42
Branch analysis from position: 33
Branch analysis from position: 6
2 jumps found. (Code = 44) Position 1 = 15, Position 2 = 6
Branch analysis from position: 15
Branch analysis from position: 6
filename:       /in/CMktE
function name:  (null)
number of ops:  84
compiled vars:  !0 = $t, !1 = $i, !2 = $start, !3 = $end, !4 = $rangeArr, !5 = $rangeObj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   INIT_FCALL                                               'microtime'
          1        SEND_VAL                                                 <true>
          2        DO_ICALL                                         $6      
          3        ASSIGN                                                   !0, $6
   30     4        ASSIGN                                                   !1, 0
          5      > JMP                                                      ->13
   31     6    >   ASSIGN                                                   !2, !1
   32     7        ASSIGN                                                   !3, !1
   33     8        INIT_FCALL                                               'accepttwo'
          9        SEND_VAR                                                 !2
         10        SEND_VAR                                                 !3
         11        DO_FCALL                                      0          
   30    12        PRE_INC                                                  !1
         13    >   IS_SMALLER                                               !1, 100000
         14      > JMPNZ                                                    ~13, ->6
   35    15    >   INIT_FCALL                                               'round'
         16        INIT_FCALL                                               'microtime'
         17        SEND_VAL                                                 <true>
         18        DO_ICALL                                         $14     
         19        SUB                                              ~15     $14, !0
         20        MUL                                              ~16     ~15, 1000
         21        SEND_VAL                                                 ~16
         22        SEND_VAL                                                 2
         23        DO_ICALL                                         $17     
         24        CONCAT                                           ~18     '2+vars%3A+', $17
         25        CONCAT                                           ~19     ~18, '+ms%0A'
         26        ECHO                                                     ~19
   37    27        INIT_FCALL                                               'microtime'
         28        SEND_VAL                                                 <true>
         29        DO_ICALL                                         $20     
         30        ASSIGN                                                   !0, $20
   38    31        ASSIGN                                                   !1, 0
         32      > JMP                                                      ->40
   39    33    >   INIT_ARRAY                                       ~23     !1
         34        ADD_ARRAY_ELEMENT                                ~23     !1
         35        ASSIGN                                                   !4, ~23
   40    36        INIT_FCALL                                               'acceptone'
         37        SEND_VAR                                                 !4
         38        DO_FCALL                                      0          
   38    39        PRE_INC                                                  !1
         40    >   IS_SMALLER                                               !1, 100000
         41      > JMPNZ                                                    ~27, ->33
   42    42    >   INIT_FCALL                                               'round'
         43        INIT_FCALL                                               'microtime'
         44        SEND_VAL                                                 <true>
         45        DO_ICALL                                         $28     
         46        SUB                                              ~29     $28, !0
         47        MUL                                              ~30     ~29, 1000
         48        SEND_VAL                                                 ~30
         49        SEND_VAL                                                 2
         50        DO_ICALL                                         $31     
         51        CONCAT                                           ~32     'range+arr%3A+', $31
         52        CONCAT                                           ~33     ~32, '+ms%0A'
         53        ECHO                                                     ~33
   44    54        INIT_FCALL                                               'microtime'
         55        SEND_VAL                                                 <true>
         56        DO_ICALL                                         $34     
         57        ASSIGN                                                   !0, $34
   45    58        ASSIGN                                                   !1, 0
         59      > JMP                                                      ->69
   46    60    >   NEW                                              $37     'IndexRange'
         61        SEND_VAR_EX                                              !1
         62        SEND_VAR_EX                                              !1
         63        DO_FCALL                                      0          
         64        ASSIGN                                                   !5, $37
   47    65        INIT_FCALL                                               'acceptone'
         66        SEND_VAR                                                 !5
         67        DO_FCALL                                      0          
   45    68        PRE_INC                                                  !1
         69    >   IS_SMALLER                                               !1, 100000
         70      > JMPNZ                                                    ~42, ->60
   49    71    >   INIT_FCALL                                               'round'
         72        INIT_FCALL                                               'microtime'
         73        SEND_VAL                                                 <true>
         74        DO_ICALL                                         $43     
         75        SUB                                              ~44     $43, !0
         76        MUL                                              ~45     ~44, 1000
         77        SEND_VAL                                                 ~45
         78        SEND_VAL                                                 2
         79        DO_ICALL                                         $46     
         80        CONCAT                                           ~47     'range+obj%3A+', $46
         81        CONCAT                                           ~48     ~47, '+ms%0A'
         82        ECHO                                                     ~48
         83      > RETURN                                                   1

Function acceptone:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/CMktE
function name:  acceptOne
number of ops:  2
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   RECV                                             !0      
          1      > RETURN                                                   null

End of function acceptone

Function accepttwo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/CMktE
function name:  acceptTwo
number of ops:  3
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2      > RETURN                                                   null

End of function accepttwo

Class IndexRange:
Function __construct:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 6
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 10
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
Branch analysis from position: 6
filename:       /in/CMktE
function name:  __construct
number of ops:  11
compiled vars:  !0 = $start, !1 = $end
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV_INIT                                        !0      null
          1        RECV_INIT                                        !1      null
   16     2        TYPE_CHECK                                  1020          !0
          3      > JMPZ                                                     ~2, ->6
   17     4    >   ASSIGN_OBJ                                               'start'
          5        OP_DATA                                                  !0
   20     6    >   TYPE_CHECK                                  1020          !1
          7      > JMPZ                                                     ~4, ->10
   21     8    >   ASSIGN_OBJ                                               'end'
          9        OP_DATA                                                  !1
   23    10    > > RETURN                                                   null

End of function __construct

End of class IndexRange.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
198.85 ms | 1010 KiB | 18 Q