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() { $var = NULL; for($i=0; $i<LOOP; ++$i) { $var = 'abc'; $var .= ' some other thing '; $var .= ' 123 : 456'; } } function f2() { $var = NULL; for($i=0; $i<LOOP; ++$i) { $var = sprintf('%s%s %d : %d', 'abc', ' some other thing ', 123, 456); } } $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/QLfLa
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                                                 
   19     4        INIT_FCALL                                               'microtime'
          5        SEND_VAL                                                 <true>
          6        DO_ICALL                                         $5      
          7        ASSIGN                                                   !0, $5
   20     8        INIT_FCALL                                               'f1'
          9        DO_FCALL                                      0          
   21    10        INIT_FCALL                                               'microtime'
         11        SEND_VAL                                                 <true>
         12        DO_ICALL                                         $8      
         13        ASSIGN                                                   !1, $8
   22    14        SUB                                              ~10     !1, !0
         15        ASSIGN                                                   !2, ~10
   24    16        INIT_FCALL                                               'microtime'
         17        SEND_VAL                                                 <true>
         18        DO_ICALL                                         $12     
         19        ASSIGN                                                   !0, $12
   25    20        INIT_FCALL                                               'f2'
         21        DO_FCALL                                      0          
   26    22        INIT_FCALL                                               'microtime'
         23        SEND_VAL                                                 <true>
         24        DO_ICALL                                         $15     
         25        ASSIGN                                                   !1, $15
   27    26        SUB                                              ~17     !1, !0
         27        ASSIGN                                                   !3, ~17
   29    28        CONCAT                                           ~19     !2, '%09'
         29        ECHO                                                     ~19
   30    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 = 7
Branch analysis from position: 7
2 jumps found. (Code = 44) Position 1 = 10, Position 2 = 3
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 10, Position 2 = 3
Branch analysis from position: 10
Branch analysis from position: 3
filename:       /in/QLfLa
function name:  f1
number of ops:  11
compiled vars:  !0 = $var, !1 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   ASSIGN                                                   !0, null
    7     1        ASSIGN                                                   !1, 0
          2      > JMP                                                      ->7
    8     3    >   ASSIGN                                                   !0, 'abc'
    9     4        ASSIGN_OP                                     8          !0, '+some+other+thing+'
   10     5        ASSIGN_OP                                     8          !0, '+123+%3A+456'
    7     6        PRE_INC                                                  !1
          7    >   FETCH_CONSTANT                                   ~8      'LOOP'
          8        IS_SMALLER                                               !1, ~8
          9      > JMPNZ                                                    ~9, ->3
   12    10    > > RETURN                                                   null

End of function f1

Function f2:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
2 jumps found. (Code = 44) Position 1 = 15, Position 2 = 3
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 15, Position 2 = 3
Branch analysis from position: 15
Branch analysis from position: 3
filename:       /in/QLfLa
function name:  f2
number of ops:  16
compiled vars:  !0 = $var, !1 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   ASSIGN                                                   !0, null
   15     1        ASSIGN                                                   !1, 0
          2      > JMP                                                      ->12
   16     3    >   INIT_FCALL                                               'sprintf'
          4        SEND_VAL                                                 '%25s%25s+%25d+%3A+%25d'
          5        SEND_VAL                                                 'abc'
          6        SEND_VAL                                                 '+some+other+thing+'
          7        SEND_VAL                                                 123
          8        SEND_VAL                                                 456
          9        DO_ICALL                                         $4      
         10        ASSIGN                                                   !0, $4
   15    11        PRE_INC                                                  !1
         12    >   FETCH_CONSTANT                                   ~7      'LOOP'
         13        IS_SMALLER                                               !1, ~7
         14      > JMPNZ                                                    ~8, ->3
   18    15    > > RETURN                                                   null

End of function f2

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.93 ms | 1403 KiB | 21 Q