3v4l.org

run code in 300+ PHP versions simultaneously
<?php // needed to cope with a million entry array ini_set('memory_limit', '512M'); $limit = 100000; $text[] = "Now is the time"; $text[] = "for all good men"; $text[] = "to come to the aid"; $text[] = "of their country."; $text2['part1'] = "Now is the time"; $text2['part2'] = "for all good men"; $text2['part3'] = "to come to the aid"; $text2['part4'] = "of their country."; $bigArray = fillArray($limit); $max=count($bigArray); ####################################################### $start = microtime(TRUE); for($i=0; $i<$max; $i++) { $bigArray[$i] = $text[0]; $bigArray[$i] .= ' '; $bigArray[$i] .= $text[1]; $bigArray[$i] .= ' '; $bigArray[$i] .= $text[2]; $bigArray[$i] .= ' '; $bigArray[$i] .= $text[3]; } $results['dotequal']['time'] = microtime(TRUE) - $start; $results['dotequal']['name'] = 'Dot Equals'; ####################################################### $start = microtime(TRUE); for($i=0; $i<$max; $i++) { $bigArray[$i] = $text[0].' '.$text[1].' '.$text[2].' '.$text[3]; } $results['concat']['time'] = microtime(TRUE) - $start; $results['concat']['name'] = 'Dot Concatenation'; ####################################################### $start = microtime(TRUE); for($i=0; $i<$max; $i++) { $bigArray[$i] = "$text[0] $text[1] $text[2] $text[3]"; } $results['replace']['time'] = microtime(TRUE) - $start; $results['replace']['name'] = 'In-string Replacement'; ####################################################### $start = microtime(TRUE); for($i=0; $i<$max; $i++) { $bigArray[$i] = "{$text2['part1']} {$text2['part2']} {$text2['part3']} {$text2['part4']}"; } $results['replace2']['time'] = microtime(TRUE) - $start; $results['replace2']['name'] = 'Complex In-string Replacement'; ####################################################### $start = microtime(TRUE); for($i=0; $i<$max; $i++) { $bigArray[$i] = sprintf('%s %s %s %s', $text[0], $text[1], $text[2], $text[3]); } $results['sprintf']['time'] = microtime(TRUE) - $start; $results['sprintf']['name'] = 'Function: sprintf()'; ####################################################### $start = microtime(TRUE); for($i=0; $i<$max; $i++) { $bigArray[$i] = implode(' ', $text); } $results['implode']['time'] = microtime(TRUE) - $start; $results['implode']['name'] = 'Function: implode()'; ####################################################### foreach($results AS $test) { echo $test['name']." -- ".sprintf("%01.6f", $test['time'])."\n"; } ####################################################### function fillArray($limit) { // build huge array for($i=0; $i<$limit; $i++) { $array[] = $i; } return $array; } ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 52
Branch analysis from position: 52
2 jumps found. (Code = 44) Position 1 = 54, Position 2 = 33
Branch analysis from position: 54
1 jumps found. (Code = 42) Position 1 = 83
Branch analysis from position: 83
2 jumps found. (Code = 44) Position 1 = 85, Position 2 = 70
Branch analysis from position: 85
1 jumps found. (Code = 42) Position 1 = 115
Branch analysis from position: 115
2 jumps found. (Code = 44) Position 1 = 117, Position 2 = 101
Branch analysis from position: 117
1 jumps found. (Code = 42) Position 1 = 147
Branch analysis from position: 147
2 jumps found. (Code = 44) Position 1 = 149, Position 2 = 133
Branch analysis from position: 149
1 jumps found. (Code = 42) Position 1 = 179
Branch analysis from position: 179
2 jumps found. (Code = 44) Position 1 = 181, Position 2 = 165
Branch analysis from position: 181
1 jumps found. (Code = 42) Position 1 = 204
Branch analysis from position: 204
2 jumps found. (Code = 44) Position 1 = 206, Position 2 = 197
Branch analysis from position: 206
2 jumps found. (Code = 77) Position 1 = 217, Position 2 = 229
Branch analysis from position: 217
2 jumps found. (Code = 78) Position 1 = 218, Position 2 = 229
Branch analysis from position: 218
1 jumps found. (Code = 42) Position 1 = 217
Branch analysis from position: 217
Branch analysis from position: 229
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 229
Branch analysis from position: 197
2 jumps found. (Code = 44) Position 1 = 206, Position 2 = 197
Branch analysis from position: 206
Branch analysis from position: 197
Branch analysis from position: 165
2 jumps found. (Code = 44) Position 1 = 181, Position 2 = 165
Branch analysis from position: 181
Branch analysis from position: 165
Branch analysis from position: 133
2 jumps found. (Code = 44) Position 1 = 149, Position 2 = 133
Branch analysis from position: 149
Branch analysis from position: 133
Branch analysis from position: 101
2 jumps found. (Code = 44) Position 1 = 117, Position 2 = 101
Branch analysis from position: 117
Branch analysis from position: 101
Branch analysis from position: 70
2 jumps found. (Code = 44) Position 1 = 85, Position 2 = 70
Branch analysis from position: 85
Branch analysis from position: 70
Branch analysis from position: 33
2 jumps found. (Code = 44) Position 1 = 54, Position 2 = 33
Branch analysis from position: 54
Branch analysis from position: 33
filename:       /in/2J8Bq
function name:  (null)
number of ops:  231
compiled vars:  !0 = $limit, !1 = $text, !2 = $text2, !3 = $bigArray, !4 = $max, !5 = $start, !6 = $i, !7 = $results, !8 = $test
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   INIT_FCALL                                               'ini_set'
          1        SEND_VAL                                                 'memory_limit'
          2        SEND_VAL                                                 '512M'
          3        DO_ICALL                                                 
    6     4        ASSIGN                                                   !0, 100000
    8     5        ASSIGN_DIM                                               !1
          6        OP_DATA                                                  'Now+is+the+time'
    9     7        ASSIGN_DIM                                               !1
          8        OP_DATA                                                  'for+all+good+men'
   10     9        ASSIGN_DIM                                               !1
         10        OP_DATA                                                  'to+come+to+the+aid'
   11    11        ASSIGN_DIM                                               !1
         12        OP_DATA                                                  'of+their+country.'
   13    13        ASSIGN_DIM                                               !2, 'part1'
         14        OP_DATA                                                  'Now+is+the+time'
   14    15        ASSIGN_DIM                                               !2, 'part2'
         16        OP_DATA                                                  'for+all+good+men'
   15    17        ASSIGN_DIM                                               !2, 'part3'
         18        OP_DATA                                                  'to+come+to+the+aid'
   16    19        ASSIGN_DIM                                               !2, 'part4'
         20        OP_DATA                                                  'of+their+country.'
   18    21        INIT_FCALL_BY_NAME                                       'fillArray'
         22        SEND_VAR_EX                                              !0
         23        DO_FCALL                                      0  $19     
         24        ASSIGN                                                   !3, $19
   20    25        COUNT                                            ~21     !3
         26        ASSIGN                                                   !4, ~21
   24    27        INIT_FCALL                                               'microtime'
         28        SEND_VAL                                                 <true>
         29        DO_ICALL                                         $23     
         30        ASSIGN                                                   !5, $23
   26    31        ASSIGN                                                   !6, 0
         32      > JMP                                                      ->52
   27    33    >   FETCH_DIM_R                                      ~27     !1, 0
         34        ASSIGN_DIM                                               !3, !6
         35        OP_DATA                                                  ~27
   28    36        ASSIGN_DIM_OP                .=               8          !3, !6
         37        OP_DATA                                                  '+'
   29    38        FETCH_DIM_R                                      ~30     !1, 1
         39        ASSIGN_DIM_OP                .=               8          !3, !6
         40        OP_DATA                                                  ~30
   30    41        ASSIGN_DIM_OP                .=               8          !3, !6
         42        OP_DATA                                                  '+'
   31    43        FETCH_DIM_R                                      ~33     !1, 2
         44        ASSIGN_DIM_OP                .=               8          !3, !6
         45        OP_DATA                                                  ~33
   32    46        ASSIGN_DIM_OP                .=               8          !3, !6
         47        OP_DATA                                                  '+'
   33    48        FETCH_DIM_R                                      ~36     !1, 3
         49        ASSIGN_DIM_OP                .=               8          !3, !6
         50        OP_DATA                                                  ~36
   26    51        PRE_INC                                                  !6
         52    >   IS_SMALLER                                               !6, !4
         53      > JMPNZ                                                    ~38, ->33
   36    54    >   INIT_FCALL                                               'microtime'
         55        SEND_VAL                                                 <true>
         56        DO_ICALL                                         $41     
         57        SUB                                              ~42     $41, !5
         58        FETCH_DIM_W                                      $39     !7, 'dotequal'
         59        ASSIGN_DIM                                               $39, 'time'
         60        OP_DATA                                                  ~42
   37    61        FETCH_DIM_W                                      $43     !7, 'dotequal'
         62        ASSIGN_DIM                                               $43, 'name'
         63        OP_DATA                                                  'Dot+Equals'
   41    64        INIT_FCALL                                               'microtime'
         65        SEND_VAL                                                 <true>
         66        DO_ICALL                                         $45     
         67        ASSIGN                                                   !5, $45
   43    68        ASSIGN                                                   !6, 0
         69      > JMP                                                      ->83
   44    70    >   FETCH_DIM_R                                      ~49     !1, 0
         71        CONCAT                                           ~50     ~49, '+'
         72        FETCH_DIM_R                                      ~51     !1, 1
         73        CONCAT                                           ~52     ~50, ~51
         74        CONCAT                                           ~53     ~52, '+'
         75        FETCH_DIM_R                                      ~54     !1, 2
         76        CONCAT                                           ~55     ~53, ~54
         77        CONCAT                                           ~56     ~55, '+'
         78        FETCH_DIM_R                                      ~57     !1, 3
         79        CONCAT                                           ~58     ~56, ~57
         80        ASSIGN_DIM                                               !3, !6
         81        OP_DATA                                                  ~58
   43    82        PRE_INC                                                  !6
         83    >   IS_SMALLER                                               !6, !4
         84      > JMPNZ                                                    ~60, ->70
   47    85    >   INIT_FCALL                                               'microtime'
         86        SEND_VAL                                                 <true>
         87        DO_ICALL                                         $63     
         88        SUB                                              ~64     $63, !5
         89        FETCH_DIM_W                                      $61     !7, 'concat'
         90        ASSIGN_DIM                                               $61, 'time'
         91        OP_DATA                                                  ~64
   48    92        FETCH_DIM_W                                      $65     !7, 'concat'
         93        ASSIGN_DIM                                               $65, 'name'
         94        OP_DATA                                                  'Dot+Concatenation'
   52    95        INIT_FCALL                                               'microtime'
         96        SEND_VAL                                                 <true>
         97        DO_ICALL                                         $67     
         98        ASSIGN                                                   !5, $67
   54    99        ASSIGN                                                   !6, 0
        100      > JMP                                                      ->115
   55   101    >   FETCH_DIM_R                                      ~71     !1, 0
        102        ROPE_INIT                                     7  ~76     ~71
        103        ROPE_ADD                                      1  ~76     ~76, '+'
        104        FETCH_DIM_R                                      ~72     !1, 1
        105        ROPE_ADD                                      2  ~76     ~76, ~72
        106        ROPE_ADD                                      3  ~76     ~76, '+'
        107        FETCH_DIM_R                                      ~73     !1, 2
        108        ROPE_ADD                                      4  ~76     ~76, ~73
        109        ROPE_ADD                                      5  ~76     ~76, '+'
        110        FETCH_DIM_R                                      ~74     !1, 3
        111        ROPE_END                                      6  ~75     ~76, ~74
        112        ASSIGN_DIM                                               !3, !6
        113        OP_DATA                                                  ~75
   54   114        PRE_INC                                                  !6
        115    >   IS_SMALLER                                               !6, !4
        116      > JMPNZ                                                    ~81, ->101
   58   117    >   INIT_FCALL                                               'microtime'
        118        SEND_VAL                                                 <true>
        119        DO_ICALL                                         $84     
        120        SUB                                              ~85     $84, !5
        121        FETCH_DIM_W                                      $82     !7, 'replace'
        122        ASSIGN_DIM                                               $82, 'time'
        123        OP_DATA                                                  ~85
   59   124        FETCH_DIM_W                                      $86     !7, 'replace'
        125        ASSIGN_DIM                                               $86, 'name'
        126        OP_DATA                                                  'In-string+Replacement'
   63   127        INIT_FCALL                                               'microtime'
        128        SEND_VAL                                                 <true>
        129        DO_ICALL                                         $88     
        130        ASSIGN                                                   !5, $88
   65   131        ASSIGN                                                   !6, 0
        132      > JMP                                                      ->147
   66   133    >   FETCH_DIM_R                                      ~92     !2, 'part1'
        134        ROPE_INIT                                     7  ~97     ~92
        135        ROPE_ADD                                      1  ~97     ~97, '+'
        136        FETCH_DIM_R                                      ~93     !2, 'part2'
        137        ROPE_ADD                                      2  ~97     ~97, ~93
        138        ROPE_ADD                                      3  ~97     ~97, '+'
        139        FETCH_DIM_R                                      ~94     !2, 'part3'
        140        ROPE_ADD                                      4  ~97     ~97, ~94
        141        ROPE_ADD                                      5  ~97     ~97, '+'
        142        FETCH_DIM_R                                      ~95     !2, 'part4'
        143        ROPE_END                                      6  ~96     ~97, ~95
        144        ASSIGN_DIM                                               !3, !6
        145        OP_DATA                                                  ~96
   65   146        PRE_INC                                                  !6
        147    >   IS_SMALLER                                               !6, !4
        148      > JMPNZ                                                    ~102, ->133
   69   149    >   INIT_FCALL                                               'microtime'
        150        SEND_VAL                                                 <true>
        151        DO_ICALL                                         $105    
        152        SUB                                              ~106    $105, !5
        153        FETCH_DIM_W                                      $103    !7, 'replace2'
        154        ASSIGN_DIM                                               $103, 'time'
        155        OP_DATA                                                  ~106
   70   156        FETCH_DIM_W                                      $107    !7, 'replace2'
        157        ASSIGN_DIM                                               $107, 'name'
        158        OP_DATA                                                  'Complex+In-string+Replacement'
   74   159        INIT_FCALL                                               'microtime'
        160        SEND_VAL                                                 <true>
        161        DO_ICALL                                         $109    
        162        ASSIGN                                                   !5, $109
   76   163        ASSIGN                                                   !6, 0
        164      > JMP                                                      ->179
   77   165    >   INIT_FCALL                                               'sprintf'
        166        SEND_VAL                                                 '%25s+%25s+%25s+%25s'
        167        FETCH_DIM_R                                      ~113    !1, 0
        168        SEND_VAL                                                 ~113
        169        FETCH_DIM_R                                      ~114    !1, 1
        170        SEND_VAL                                                 ~114
        171        FETCH_DIM_R                                      ~115    !1, 2
        172        SEND_VAL                                                 ~115
        173        FETCH_DIM_R                                      ~116    !1, 3
        174        SEND_VAL                                                 ~116
        175        DO_ICALL                                         $117    
        176        ASSIGN_DIM                                               !3, !6
        177        OP_DATA                                                  $117
   76   178        PRE_INC                                                  !6
        179    >   IS_SMALLER                                               !6, !4
        180      > JMPNZ                                                    ~119, ->165
   80   181    >   INIT_FCALL                                               'microtime'
        182        SEND_VAL                                                 <true>
        183        DO_ICALL                                         $122    
        184        SUB                                              ~123    $122, !5
        185        FETCH_DIM_W                                      $120    !7, 'sprintf'
        186        ASSIGN_DIM                                               $120, 'time'
        187        OP_DATA                                                  ~123
   81   188        FETCH_DIM_W                                      $124    !7, 'sprintf'
        189        ASSIGN_DIM                                               $124, 'name'
        190        OP_DATA                                                  'Function%3A+sprintf%28%29'
   85   191        INIT_FCALL                                               'microtime'
        192        SEND_VAL                                                 <true>
        193        DO_ICALL                                         $126    
        194        ASSIGN                                                   !5, $126
   87   195        ASSIGN                                                   !6, 0
        196      > JMP                                                      ->204
   88   197    >   INIT_FCALL                                               'implode'
        198        SEND_VAL                                                 '+'
        199        SEND_VAR                                                 !1
        200        DO_ICALL                                         $130    
        201        ASSIGN_DIM                                               !3, !6
        202        OP_DATA                                                  $130
   87   203        PRE_INC                                                  !6
        204    >   IS_SMALLER                                               !6, !4
        205      > JMPNZ                                                    ~132, ->197
   91   206    >   INIT_FCALL                                               'microtime'
        207        SEND_VAL                                                 <true>
        208        DO_ICALL                                         $135    
        209        SUB                                              ~136    $135, !5
        210        FETCH_DIM_W                                      $133    !7, 'implode'
        211        ASSIGN_DIM                                               $133, 'time'
        212        OP_DATA                                                  ~136
   92   213        FETCH_DIM_W                                      $137    !7, 'implode'
        214        ASSIGN_DIM                                               $137, 'name'
        215        OP_DATA                                                  'Function%3A+implode%28%29'
   96   216      > FE_RESET_R                                       $139    !7, ->229
        217    > > FE_FETCH_R                                               $139, !8, ->229
   97   218    >   FETCH_DIM_R                                      ~140    !8, 'name'
        219        CONCAT                                           ~141    ~140, '+--+'
        220        INIT_FCALL                                               'sprintf'
        221        SEND_VAL                                                 '%2501.6f'
        222        FETCH_DIM_R                                      ~142    !8, 'time'
        223        SEND_VAL                                                 ~142
        224        DO_ICALL                                         $143    
        225        CONCAT                                           ~144    ~141, $143
        226        CONCAT                                           ~145    ~144, '%0A'
        227        ECHO                                                     ~145
   96   228      > JMP                                                      ->217
        229    >   FE_FREE                                                  $139
  110   230      > RETURN                                                   1

Function fillarray:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
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/2J8Bq
function name:  fillArray
number of ops:  10
compiled vars:  !0 = $limit, !1 = $i, !2 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  102     0  E >   RECV                                             !0      
  104     1        ASSIGN                                                   !1, 0
          2      > JMP                                                      ->6
  105     3    >   ASSIGN_DIM                                               !2
          4        OP_DATA                                                  !1
  104     5        PRE_INC                                                  !1
          6    >   IS_SMALLER                                               !1, !0
          7      > JMPNZ                                                    ~6, ->3
  107     8    > > RETURN                                                   !2
  108     9*     > RETURN                                                   null

End of function fillarray

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.46 ms | 1416 KiB | 21 Q