3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* How many times the code under test should run in each function */ define('LOOP',1000000); function f1() { $path = NULL; for($i=0; $i<LOOP; ++$i) { $md5 = md5(str_shuffle('asbfdgdg5y54yy5rh45g5ge5g5g')); $yy = date('y'); $ab = substr($md5, 0, 2); $cd = substr($md5, 2, 2); $path = 'some' . '/'; $path .= $yy . '/'; $path .= $ab . '/'; $path .= $cd . '/'; } } function f2() { $path = NULL; for($i=0; $i<LOOP; ++$i) { $md5 = md5(str_shuffle('asbfdgdg5y54yy5rh45g5ge5g5g')); $yy = date('y'); $ab = substr($md5, 0, 2); $cd = substr($md5, 2, 2); $path = sprintf('%s/%s/%s/%s', 'some', $yy, $ab, $cd); } } $start = microtime(true); f1(); $stop = microtime(true); $time1 = $stop - $start; $start = microtime(true); f2(); $stop = microtime(true); $time2 = $stop - $start; echo $time1 . "\t"; echo $time2 . "\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9YuOt
function name:  (null)
number of ops:  33
compiled vars:  !0 = $start, !1 = $stop, !2 = $time1, !3 = $time2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'define'
          1        SEND_VAL                                                 'LOOP'
          2        SEND_VAL                                                 1000000
          3        DO_ICALL                                                 
   36     4        INIT_FCALL                                               'microtime'
          5        SEND_VAL                                                 <true>
          6        DO_ICALL                                         $5      
          7        ASSIGN                                                   !0, $5
   37     8        INIT_FCALL                                               'f1'
          9        DO_FCALL                                      0          
   38    10        INIT_FCALL                                               'microtime'
         11        SEND_VAL                                                 <true>
         12        DO_ICALL                                         $8      
         13        ASSIGN                                                   !1, $8
   39    14        SUB                                              ~10     !1, !0
         15        ASSIGN                                                   !2, ~10
   41    16        INIT_FCALL                                               'microtime'
         17        SEND_VAL                                                 <true>
         18        DO_ICALL                                         $12     
         19        ASSIGN                                                   !0, $12
   42    20        INIT_FCALL                                               'f2'
         21        DO_FCALL                                      0          
   43    22        INIT_FCALL                                               'microtime'
         23        SEND_VAL                                                 <true>
         24        DO_ICALL                                         $15     
         25        ASSIGN                                                   !1, $15
   44    26        SUB                                              ~17     !1, !0
         27        ASSIGN                                                   !3, ~17
   46    28        CONCAT                                           ~19     !2, '%09'
         29        ECHO                                                     ~19
         30        CONCAT                                           ~20     !3, '%0A'
         31        ECHO                                                     ~20
         32      > RETURN                                                   1

Function f1:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 34
Branch analysis from position: 34
2 jumps found. (Code = 44) Position 1 = 37, Position 2 = 3
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 37, Position 2 = 3
Branch analysis from position: 37
Branch analysis from position: 3
filename:       /in/9YuOt
function name:  f1
number of ops:  38
compiled vars:  !0 = $path, !1 = $i, !2 = $md5, !3 = $yy, !4 = $ab, !5 = $cd
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   ASSIGN                                                   !0, null
    8     1        ASSIGN                                                   !1, 0
          2      > JMP                                                      ->34
    9     3    >   INIT_FCALL                                               'md5'
          4        INIT_FCALL                                               'str_shuffle'
          5        SEND_VAL                                                 'asbfdgdg5y54yy5rh45g5ge5g5g'
          6        DO_ICALL                                         $8      
          7        SEND_VAR                                                 $8
          8        DO_ICALL                                         $9      
          9        ASSIGN                                                   !2, $9
   11    10        INIT_FCALL                                               'date'
         11        SEND_VAL                                                 'y'
         12        DO_ICALL                                         $11     
         13        ASSIGN                                                   !3, $11
   12    14        INIT_FCALL                                               'substr'
         15        SEND_VAR                                                 !2
         16        SEND_VAL                                                 0
         17        SEND_VAL                                                 2
         18        DO_ICALL                                         $13     
         19        ASSIGN                                                   !4, $13
   13    20        INIT_FCALL                                               'substr'
         21        SEND_VAR                                                 !2
         22        SEND_VAL                                                 2
         23        SEND_VAL                                                 2
         24        DO_ICALL                                         $15     
         25        ASSIGN                                                   !5, $15
   15    26        ASSIGN                                                   !0, 'some%2F'
   16    27        CONCAT                                           ~18     !3, '%2F'
         28        ASSIGN_OP                                     8          !0, ~18
   17    29        CONCAT                                           ~20     !4, '%2F'
         30        ASSIGN_OP                                     8          !0, ~20
   18    31        CONCAT                                           ~22     !5, '%2F'
         32        ASSIGN_OP                                     8          !0, ~22
    8    33        PRE_INC                                                  !1
         34    >   FETCH_CONSTANT                                   ~25     'LOOP'
         35        IS_SMALLER                                               !1, ~25
         36      > JMPNZ                                                    ~26, ->3
   20    37    > > RETURN                                                   null

End of function f1

Function f2:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 35
Branch analysis from position: 35
2 jumps found. (Code = 44) Position 1 = 38, Position 2 = 3
Branch analysis from position: 38
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 38, Position 2 = 3
Branch analysis from position: 38
Branch analysis from position: 3
filename:       /in/9YuOt
function name:  f2
number of ops:  39
compiled vars:  !0 = $path, !1 = $i, !2 = $md5, !3 = $yy, !4 = $ab, !5 = $cd
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   ASSIGN                                                   !0, null
   25     1        ASSIGN                                                   !1, 0
          2      > JMP                                                      ->35
   26     3    >   INIT_FCALL                                               'md5'
          4        INIT_FCALL                                               'str_shuffle'
          5        SEND_VAL                                                 'asbfdgdg5y54yy5rh45g5ge5g5g'
          6        DO_ICALL                                         $8      
          7        SEND_VAR                                                 $8
          8        DO_ICALL                                         $9      
          9        ASSIGN                                                   !2, $9
   28    10        INIT_FCALL                                               'date'
         11        SEND_VAL                                                 'y'
         12        DO_ICALL                                         $11     
         13        ASSIGN                                                   !3, $11
   29    14        INIT_FCALL                                               'substr'
         15        SEND_VAR                                                 !2
         16        SEND_VAL                                                 0
         17        SEND_VAL                                                 2
         18        DO_ICALL                                         $13     
         19        ASSIGN                                                   !4, $13
   30    20        INIT_FCALL                                               'substr'
         21        SEND_VAR                                                 !2
         22        SEND_VAL                                                 2
         23        SEND_VAL                                                 2
         24        DO_ICALL                                         $15     
         25        ASSIGN                                                   !5, $15
   32    26        INIT_FCALL                                               'sprintf'
         27        SEND_VAL                                                 '%25s%2F%25s%2F%25s%2F%25s'
         28        SEND_VAL                                                 'some'
         29        SEND_VAR                                                 !3
         30        SEND_VAR                                                 !4
         31        SEND_VAR                                                 !5
         32        DO_ICALL                                         $17     
         33        ASSIGN                                                   !0, $17
   25    34        PRE_INC                                                  !1
         35    >   FETCH_CONSTANT                                   ~20     'LOOP'
         36        IS_SMALLER                                               !1, ~20
         37      > JMPNZ                                                    ~21, ->3
   34    38    > > RETURN                                                   null

End of function f2

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.74 ms | 1398 KiB | 29 Q