3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* How many times the code under test should run in each function */ define('LOOP',100); function f1(&$md5) { $path = NULL; $yy = date('y'); $ab = substr($md5, 0, 2); $cd = substr($md5, 2, 2); for($i=0; $i<LOOP; ++$i) { $path = 'some' . '/'; $path .= $yy . '/'; $path .= $ab . '/'; $path .= $cd . '/'; } } function f2(&$md5) { $path = NULL; $yy = date('y'); $ab = substr($md5, 0, 2); $cd = substr($md5, 2, 2); for($i=0; $i<LOOP; ++$i) { $path = sprintf('%s/%s/%s/%s', 'some', $yy, $ab, $cd); } } $md5 = md5(str_shuffle('ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890')); $start = microtime(true); f1($md5); $stop = microtime(true); $time1 = $stop - $start; $start = microtime(true); f2($md5); $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/0jtG3
function name:  (null)
number of ops:  42
compiled vars:  !0 = $md5, !1 = $start, !2 = $stop, !3 = $time1, !4 = $time2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'define'
          1        SEND_VAL                                                 'LOOP'
          2        SEND_VAL                                                 100
          3        DO_ICALL                                                 
   30     4        INIT_FCALL                                               'md5'
          5        INIT_FCALL                                               'str_shuffle'
          6        SEND_VAL                                                 'ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'
          7        DO_ICALL                                         $6      
          8        SEND_VAR                                                 $6
          9        DO_ICALL                                         $7      
         10        ASSIGN                                                   !0, $7
   32    11        INIT_FCALL                                               'microtime'
         12        SEND_VAL                                                 <true>
         13        DO_ICALL                                         $9      
         14        ASSIGN                                                   !1, $9
   33    15        INIT_FCALL                                               'f1'
         16        SEND_REF                                                 !0
         17        DO_FCALL                                      0          
   34    18        INIT_FCALL                                               'microtime'
         19        SEND_VAL                                                 <true>
         20        DO_ICALL                                         $12     
         21        ASSIGN                                                   !2, $12
   35    22        SUB                                              ~14     !2, !1
         23        ASSIGN                                                   !3, ~14
   37    24        INIT_FCALL                                               'microtime'
         25        SEND_VAL                                                 <true>
         26        DO_ICALL                                         $16     
         27        ASSIGN                                                   !1, $16
   38    28        INIT_FCALL                                               'f2'
         29        SEND_REF                                                 !0
         30        DO_FCALL                                      0          
   39    31        INIT_FCALL                                               'microtime'
         32        SEND_VAL                                                 <true>
         33        DO_ICALL                                         $19     
         34        ASSIGN                                                   !2, $19
   40    35        SUB                                              ~21     !2, !1
         36        ASSIGN                                                   !4, ~21
   42    37        CONCAT                                           ~23     !3, '%09'
         38        ECHO                                                     ~23
         39        CONCAT                                           ~24     !4, '%0A'
         40        ECHO                                                     ~24
         41      > RETURN                                                   1

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

End of function f1

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

End of function f2

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.16 ms | 1407 KiB | 29 Q