3v4l.org

run code in 300+ PHP versions simultaneously
<?php $input = '1|27|31|33'; $separator = '##|##'; $iterations = 100000; $time = microtime(true); for ($i = 0; $i < $iterations; $i++) { $result = str_replace('|', $separator, $input); } $time1 = microtime(true); echo 'processed in ' . (($time1 - $time) * 1000) . ' millisecs'; 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 in ' . (($time2 - $time1) * 1000) . ' millisecs';
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 = 52
Branch analysis from position: 52
2 jumps found. (Code = 44) Position 1 = 54, Position 2 = 29
Branch analysis from position: 54
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
2 jumps found. (Code = 77) Position 1 = 43, Position 2 = 50
Branch analysis from position: 43
2 jumps found. (Code = 78) Position 1 = 44, Position 2 = 50
Branch analysis from position: 44
2 jumps found. (Code = 43) Position 1 = 48, Position 2 = 49
Branch analysis from position: 48
1 jumps found. (Code = 42) Position 1 = 43
Branch analysis from position: 43
Branch analysis from position: 49
Branch analysis from position: 50
2 jumps found. (Code = 44) Position 1 = 54, Position 2 = 29
Branch analysis from position: 54
Branch analysis from position: 29
Branch analysis from position: 50
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/siT0K
function name:  (null)
number of ops:  64
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, 100000
    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        SUB                                              ~22     !6, !3
         23        MUL                                              ~23     ~22, 1000
         24        CONCAT                                           ~24     'processed+in+', ~23
         25        CONCAT                                           ~25     ~24, '+millisecs'
         26        ECHO                                                     ~25
   16    27        ASSIGN                                                   !4, 0
         28      > JMP                                                      ->52
   17    29    >   ASSIGN                                                   !5, ''
   18    30        NEW                                              $28     'CachingIterator'
         31        NEW                                              $29     'ArrayIterator'
         32        INIT_FCALL                                               'explode'
         33        SEND_VAL                                                 '%7C'
         34        SEND_VAR                                                 !0
         35        DO_ICALL                                         $30     
         36        SEND_VAR_NO_REF_EX                                       $30
         37        DO_FCALL                                      0          
         38        SEND_VAR_NO_REF_EX                                       $29
         39        SEND_VAL_EX                                              256
         40        DO_FCALL                                      0          
         41        ASSIGN                                                   !7, $28
   19    42      > FE_RESET_R                                       $34     !7, ->50
         43    > > FE_FETCH_R                                               $34, !8, ->50
   20    44    >   ASSIGN_OP                                     8          !5, !8
   21    45        INIT_METHOD_CALL                                         !7, 'hasNext'
         46        DO_FCALL                                      0  $36     
         47      > JMPZ                                                     $36, ->49
   22    48    >   ASSIGN_OP                                     8          !5, !1
   19    49    > > JMP                                                      ->43
         50    >   FE_FREE                                                  $34
   16    51        PRE_INC                                                  !4
         52    >   IS_SMALLER                                               !4, !2
         53      > JMPNZ                                                    ~39, ->29
   27    54    >   INIT_FCALL                                               'microtime'
         55        SEND_VAL                                                 <true>
         56        DO_ICALL                                         $40     
         57        ASSIGN                                                   !9, $40
   28    58        SUB                                              ~42     !9, !6
         59        MUL                                              ~43     ~42, 1000
         60        CONCAT                                           ~44     'processed+in+', ~43
         61        CONCAT                                           ~45     ~44, '+millisecs'
         62        ECHO                                                     ~45
         63      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.86 ms | 1392 KiB | 19 Q