3v4l.org

run code in 300+ PHP versions simultaneously
<?php function outside() { $c = 100; $o = ''; $a = [ '1' => 'one', '2' => 'two' ]; while ( --$c ) { $o .= strtr( $c, $a ); } return $o; } function inside() { $c = 100; $o = ''; while ( --$c ) { $a = [ '1' => 'one', '2' => 'two' ]; $o .= strtr( $c, $a ); } return $o; } $it = 100; $ns = -hrtime( true ); $c = $it; $l = 0; while ( --$c ) { $l += strlen( outside() ); } $ns += hrtime( true ); echo "outside: " . ( $ns / $it / 1e3 ) . " µs/it\n"; $it = 100; $ns = -hrtime( true ); $c = $it; $l = 0; while ( --$c ) { $l += strlen( inside() ); } $ns += hrtime( true ); echo "inside: " . ( $ns / $it / 1e3 ) . " µs/it\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
2 jumps found. (Code = 44) Position 1 = 15, Position 2 = 9
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
2 jumps found. (Code = 44) Position 1 = 39, Position 2 = 33
Branch analysis from position: 39
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 33
2 jumps found. (Code = 44) Position 1 = 39, Position 2 = 33
Branch analysis from position: 39
Branch analysis from position: 33
Branch analysis from position: 9
2 jumps found. (Code = 44) Position 1 = 15, Position 2 = 9
Branch analysis from position: 15
Branch analysis from position: 9
filename:       /in/lDqdY
function name:  (null)
number of ops:  49
compiled vars:  !0 = $it, !1 = $ns, !2 = $c, !3 = $l
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   ASSIGN                                                   !0, 100
   24     1        INIT_FCALL                                               'hrtime'
          2        SEND_VAL                                                 <true>
          3        DO_ICALL                                         $5      
          4        MUL                                              ~6      $5, -1
          5        ASSIGN                                                   !1, ~6
   25     6        ASSIGN                                                   !2, !0
   26     7        ASSIGN                                                   !3, 0
   27     8      > JMP                                                      ->13
   28     9    >   INIT_FCALL                                               'outside'
         10        DO_FCALL                                      0  $10     
         11        STRLEN                                           ~11     $10
         12        ASSIGN_OP                                     1          !3, ~11
   27    13    >   PRE_DEC                                          ~13     !2
         14      > JMPNZ                                                    ~13, ->9
   30    15    >   INIT_FCALL                                               'hrtime'
         16        SEND_VAL                                                 <true>
         17        DO_ICALL                                         $14     
         18        ASSIGN_OP                                     1          !1, $14
   31    19        DIV                                              ~16     !1, !0
         20        DIV                                              ~17     ~16, 1000
         21        CONCAT                                           ~18     'outside%3A+', ~17
         22        CONCAT                                           ~19     ~18, '+%C2%B5s%2Fit%0A'
         23        ECHO                                                     ~19
   33    24        ASSIGN                                                   !0, 100
   34    25        INIT_FCALL                                               'hrtime'
         26        SEND_VAL                                                 <true>
         27        DO_ICALL                                         $21     
         28        MUL                                              ~22     $21, -1
         29        ASSIGN                                                   !1, ~22
   35    30        ASSIGN                                                   !2, !0
   36    31        ASSIGN                                                   !3, 0
   37    32      > JMP                                                      ->37
   38    33    >   INIT_FCALL                                               'inside'
         34        DO_FCALL                                      0  $26     
         35        STRLEN                                           ~27     $26
         36        ASSIGN_OP                                     1          !3, ~27
   37    37    >   PRE_DEC                                          ~29     !2
         38      > JMPNZ                                                    ~29, ->33
   40    39    >   INIT_FCALL                                               'hrtime'
         40        SEND_VAL                                                 <true>
         41        DO_ICALL                                         $30     
         42        ASSIGN_OP                                     1          !1, $30
   41    43        DIV                                              ~32     !1, !0
         44        DIV                                              ~33     ~32, 1000
         45        CONCAT                                           ~34     'inside%3A+', ~33
         46        CONCAT                                           ~35     ~34, '+%C2%B5s%2Fit%0A'
         47        ECHO                                                     ~35
         48      > RETURN                                                   1

Function outside:
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 = 11, Position 2 = 4
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
2 jumps found. (Code = 44) Position 1 = 11, Position 2 = 4
Branch analysis from position: 11
Branch analysis from position: 4
filename:       /in/lDqdY
function name:  outside
number of ops:  13
compiled vars:  !0 = $c, !1 = $o, !2 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   ASSIGN                                                   !0, 100
    5     1        ASSIGN                                                   !1, ''
    6     2        ASSIGN                                                   !2, <array>
    7     3      > JMP                                                      ->9
    8     4    >   INIT_FCALL                                               'strtr'
          5        SEND_VAR                                                 !0
          6        SEND_VAR                                                 !2
          7        DO_ICALL                                         $6      
          8        ASSIGN_OP                                     8          !1, $6
    7     9    >   PRE_DEC                                          ~8      !0
         10      > JMPNZ                                                    ~8, ->4
   10    11    > > RETURN                                                   !1
   11    12*     > RETURN                                                   null

End of function outside

Function inside:
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 = 11, Position 2 = 3
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 11, Position 2 = 3
Branch analysis from position: 11
Branch analysis from position: 3
filename:       /in/lDqdY
function name:  inside
number of ops:  13
compiled vars:  !0 = $c, !1 = $o, !2 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   ASSIGN                                                   !0, 100
   15     1        ASSIGN                                                   !1, ''
   16     2      > JMP                                                      ->9
   17     3    >   ASSIGN                                                   !2, <array>
   18     4        INIT_FCALL                                               'strtr'
          5        SEND_VAR                                                 !0
          6        SEND_VAR                                                 !2
          7        DO_ICALL                                         $6      
          8        ASSIGN_OP                                     8          !1, $6
   16     9    >   PRE_DEC                                          ~8      !0
         10      > JMPNZ                                                    ~8, ->3
   20    11    > > RETURN                                                   !1
   21    12*     > RETURN                                                   null

End of function inside

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
145.81 ms | 1100 KiB | 17 Q