3v4l.org

run code in 300+ PHP versions simultaneously
<?php function foo() { $bar = mt_rand(); } $iterations = 1000000; $a = microtime(true); for ($i = 0; $i < $iterations; $i++) { $bar = mt_rand(); } $b = microtime(true); for ($i = 0; $i < $iterations; $i++) { foo(); } $c = microtime(true); $ab = $b - $a; $bc = $c - $b; $abcPercent = (($bc / $ab) - 1) * 100; printf('Direct: %s seconds' . PHP_EOL, number_format($ab, 4)); printf('Function: %s seconds (%s%% more!)', number_format($bc, 4), number_format($abcPercent, 2));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
2 jumps found. (Code = 44) Position 1 = 13, Position 2 = 7
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
2 jumps found. (Code = 44) Position 1 = 24, Position 2 = 19
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
2 jumps found. (Code = 44) Position 1 = 24, Position 2 = 19
Branch analysis from position: 24
Branch analysis from position: 19
Branch analysis from position: 7
2 jumps found. (Code = 44) Position 1 = 13, Position 2 = 7
Branch analysis from position: 13
Branch analysis from position: 7
filename:       /in/HmmIB
function name:  (null)
number of ops:  58
compiled vars:  !0 = $iterations, !1 = $a, !2 = $i, !3 = $bar, !4 = $b, !5 = $c, !6 = $ab, !7 = $bc, !8 = $abcPercent
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   ASSIGN                                                   !0, 1000000
    9     1        INIT_FCALL                                               'microtime'
          2        SEND_VAL                                                 <true>
          3        DO_ICALL                                         $10     
          4        ASSIGN                                                   !1, $10
   11     5        ASSIGN                                                   !2, 0
          6      > JMP                                                      ->11
   12     7    >   INIT_FCALL                                               'mt_rand'
          8        DO_ICALL                                         $13     
          9        ASSIGN                                                   !3, $13
   11    10        PRE_INC                                                  !2
         11    >   IS_SMALLER                                               !2, !0
         12      > JMPNZ                                                    ~16, ->7
   15    13    >   INIT_FCALL                                               'microtime'
         14        SEND_VAL                                                 <true>
         15        DO_ICALL                                         $17     
         16        ASSIGN                                                   !4, $17
   17    17        ASSIGN                                                   !2, 0
         18      > JMP                                                      ->22
   18    19    >   INIT_FCALL                                               'foo'
         20        DO_FCALL                                      0          
   17    21        PRE_INC                                                  !2
         22    >   IS_SMALLER                                               !2, !0
         23      > JMPNZ                                                    ~22, ->19
   21    24    >   INIT_FCALL                                               'microtime'
         25        SEND_VAL                                                 <true>
         26        DO_ICALL                                         $23     
         27        ASSIGN                                                   !5, $23
   23    28        SUB                                              ~25     !4, !1
         29        ASSIGN                                                   !6, ~25
   24    30        SUB                                              ~27     !5, !4
         31        ASSIGN                                                   !7, ~27
   26    32        DIV                                              ~29     !7, !6
         33        SUB                                              ~30     ~29, 1
         34        MUL                                              ~31     ~30, 100
         35        ASSIGN                                                   !8, ~31
   28    36        INIT_FCALL                                               'printf'
         37        SEND_VAL                                                 'Direct%3A+%25s+seconds%0A'
         38        INIT_FCALL                                               'number_format'
         39        SEND_VAR                                                 !6
         40        SEND_VAL                                                 4
         41        DO_ICALL                                         $33     
         42        SEND_VAR                                                 $33
         43        DO_ICALL                                                 
   29    44        INIT_FCALL                                               'printf'
         45        SEND_VAL                                                 'Function%3A+%25s+seconds+%28%25s%25%25+more%21%29'
         46        INIT_FCALL                                               'number_format'
         47        SEND_VAR                                                 !7
         48        SEND_VAL                                                 4
         49        DO_ICALL                                         $35     
         50        SEND_VAR                                                 $35
         51        INIT_FCALL                                               'number_format'
         52        SEND_VAR                                                 !8
         53        SEND_VAL                                                 2
         54        DO_ICALL                                         $36     
         55        SEND_VAR                                                 $36
         56        DO_ICALL                                                 
         57      > RETURN                                                   1

Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HmmIB
function name:  foo
number of ops:  4
compiled vars:  !0 = $bar
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   INIT_FCALL                                               'mt_rand'
          1        DO_ICALL                                         $1      
          2        ASSIGN                                                   !0, $1
    5     3      > RETURN                                                   null

End of function foo

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.92 ms | 1447 KiB | 18 Q