3v4l.org

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