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 = 'test'.'123'.'string'; } } function f2() { $var = NULL; for($i=0; $i<LOOP; ++$i) { $var = sprintf('test%sstring', 123); } } $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/YTr8Q
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                                                 
   17     4        INIT_FCALL                                               'microtime'
          5        SEND_VAL                                                 <true>
          6        DO_ICALL                                         $5      
          7        ASSIGN                                                   !0, $5
   18     8        INIT_FCALL                                               'f1'
          9        DO_FCALL                                      0          
   19    10        INIT_FCALL                                               'microtime'
         11        SEND_VAL                                                 <true>
         12        DO_ICALL                                         $8      
         13        ASSIGN                                                   !1, $8
   20    14        SUB                                              ~10     !1, !0
         15        ASSIGN                                                   !2, ~10
   22    16        INIT_FCALL                                               'microtime'
         17        SEND_VAL                                                 <true>
         18        DO_ICALL                                         $12     
         19        ASSIGN                                                   !0, $12
   23    20        INIT_FCALL                                               'f2'
         21        DO_FCALL                                      0          
   24    22        INIT_FCALL                                               'microtime'
         23        SEND_VAL                                                 <true>
         24        DO_ICALL                                         $15     
         25        ASSIGN                                                   !1, $15
   25    26        SUB                                              ~17     !1, !0
         27        ASSIGN                                                   !3, ~17
   27    28        CONCAT                                           ~19     !2, '%09'
         29        ECHO                                                     ~19
   28    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 = 5
Branch analysis from position: 5
2 jumps found. (Code = 44) Position 1 = 8, Position 2 = 3
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 8, Position 2 = 3
Branch analysis from position: 8
Branch analysis from position: 3
filename:       /in/YTr8Q
function name:  f1
number of ops:  9
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                                                      ->5
    8     3    >   ASSIGN                                                   !0, 'test123string'
    7     4        PRE_INC                                                  !1
          5    >   FETCH_CONSTANT                                   ~6      'LOOP'
          6        IS_SMALLER                                               !1, ~6
          7      > JMPNZ                                                    ~7, ->3
   10     8    > > RETURN                                                   null

End of function f1

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

End of function f2

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
144.43 ms | 1407 KiB | 21 Q