3v4l.org

run code in 300+ PHP versions simultaneously
<?php $input = '1|27|31|33'; $separator = '##|##'; $iterations = 300000; $time = microtime(true); for ($i = 0; $i < $iterations; $i++) { $result = str_replace('|', $separator, $input); } $time1 = microtime(true); echo 'processed with str_replace in ' . round(($time1 - $time) * 1000) . ' millisecs' . PHP_EOL; for ($i = 0; $i < $iterations; $i++) { $result = ''; $it = new CachingIterator(new ArrayIterator(explode('|', $input)), CachingIterator::FULL_CACHE); foreach ($it as $categoryId) { $result .= $categoryId; if ($it->hasNext()) { $result .= $separator; } } } $time2 = microtime(true); echo 'processed with CachingIterator in ' . round(($time2 - $time1) * 1000) . ' millisecs' . PHP_EOL;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 9
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 56
Branch analysis from position: 56
2 jumps found. (Code = 44) Position 1 = 58, Position 2 = 33
Branch analysis from position: 58
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 33
2 jumps found. (Code = 77) Position 1 = 47, Position 2 = 54
Branch analysis from position: 47
2 jumps found. (Code = 78) Position 1 = 48, Position 2 = 54
Branch analysis from position: 48
2 jumps found. (Code = 43) Position 1 = 52, Position 2 = 53
Branch analysis from position: 52
1 jumps found. (Code = 42) Position 1 = 47
Branch analysis from position: 47
Branch analysis from position: 53
Branch analysis from position: 54
2 jumps found. (Code = 44) Position 1 = 58, Position 2 = 33
Branch analysis from position: 58
Branch analysis from position: 33
Branch analysis from position: 54
Branch analysis from position: 9
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 9
Branch analysis from position: 18
Branch analysis from position: 9
filename:       /in/gsE1B
function name:  (null)
number of ops:  72
compiled vars:  !0 = $input, !1 = $separator, !2 = $iterations, !3 = $time, !4 = $i, !5 = $result, !6 = $time1, !7 = $it, !8 = $categoryId, !9 = $time2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '1%7C27%7C31%7C33'
    4     1        ASSIGN                                                   !1, '%23%23%7C%23%23'
    5     2        ASSIGN                                                   !2, 300000
    7     3        INIT_FCALL                                               'microtime'
          4        SEND_VAL                                                 <true>
          5        DO_ICALL                                         $13     
          6        ASSIGN                                                   !3, $13
    9     7        ASSIGN                                                   !4, 0
          8      > JMP                                                      ->16
   10     9    >   INIT_FCALL                                               'str_replace'
         10        SEND_VAL                                                 '%7C'
         11        SEND_VAR                                                 !1
         12        SEND_VAR                                                 !0
         13        DO_ICALL                                         $16     
         14        ASSIGN                                                   !5, $16
    9    15        PRE_INC                                                  !4
         16    >   IS_SMALLER                                               !4, !2
         17      > JMPNZ                                                    ~19, ->9
   12    18    >   INIT_FCALL                                               'microtime'
         19        SEND_VAL                                                 <true>
         20        DO_ICALL                                         $20     
         21        ASSIGN                                                   !6, $20
   13    22        INIT_FCALL                                               'round'
         23        SUB                                              ~22     !6, !3
         24        MUL                                              ~23     ~22, 1000
         25        SEND_VAL                                                 ~23
         26        DO_ICALL                                         $24     
         27        CONCAT                                           ~25     'processed+with+str_replace+in+', $24
         28        CONCAT                                           ~26     ~25, '+millisecs'
         29        CONCAT                                           ~27     ~26, '%0A'
         30        ECHO                                                     ~27
   16    31        ASSIGN                                                   !4, 0
         32      > JMP                                                      ->56
   17    33    >   ASSIGN                                                   !5, ''
   18    34        NEW                                              $30     'CachingIterator'
         35        NEW                                              $31     'ArrayIterator'
         36        INIT_FCALL                                               'explode'
         37        SEND_VAL                                                 '%7C'
         38        SEND_VAR                                                 !0
         39        DO_ICALL                                         $32     
         40        SEND_VAR_NO_REF_EX                                       $32
         41        DO_FCALL                                      0          
         42        SEND_VAR_NO_REF_EX                                       $31
         43        SEND_VAL_EX                                              256
         44        DO_FCALL                                      0          
         45        ASSIGN                                                   !7, $30
   19    46      > FE_RESET_R                                       $36     !7, ->54
         47    > > FE_FETCH_R                                               $36, !8, ->54
   20    48    >   ASSIGN_OP                                     8          !5, !8
   21    49        INIT_METHOD_CALL                                         !7, 'hasNext'
         50        DO_FCALL                                      0  $38     
         51      > JMPZ                                                     $38, ->53
   22    52    >   ASSIGN_OP                                     8          !5, !1
   19    53    > > JMP                                                      ->47
         54    >   FE_FREE                                                  $36
   16    55        PRE_INC                                                  !4
         56    >   IS_SMALLER                                               !4, !2
         57      > JMPNZ                                                    ~41, ->33
   27    58    >   INIT_FCALL                                               'microtime'
         59        SEND_VAL                                                 <true>
         60        DO_ICALL                                         $42     
         61        ASSIGN                                                   !9, $42
   28    62        INIT_FCALL                                               'round'
         63        SUB                                              ~44     !9, !6
         64        MUL                                              ~45     ~44, 1000
         65        SEND_VAL                                                 ~45
         66        DO_ICALL                                         $46     
         67        CONCAT                                           ~47     'processed+with+CachingIterator+in+', $46
         68        CONCAT                                           ~48     ~47, '+millisecs'
         69        CONCAT                                           ~49     ~48, '%0A'
         70        ECHO                                                     ~49
         71      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.06 ms | 1400 KiB | 21 Q