3v4l.org

run code in 300+ PHP versions simultaneously
<?php $haystack = "abcdefghijklmnopqrstuvwxyz"; $needles = array('abc', 'xyz', '123'); foreach ($needles as $needle) { $times['strncmp'][$needle] = -microtime(true); for ($i = 0; $i < 1000000; $i++) { $result = strncmp($haystack, $needle, 3) === 0; } $times['strncmp'][$needle] += microtime(true); } foreach ($needles as $needle) { $times['strpos'][$needle] = -microtime(true); for ($i = 0; $i < 1000000; $i++) { $result = strpos($haystack, $needle) === 0; } $times['strpos'][$needle] += microtime(true); } var_export($times);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 30
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 30
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
2 jumps found. (Code = 44) Position 1 = 23, Position 2 = 13
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 13
2 jumps found. (Code = 44) Position 1 = 23, Position 2 = 13
Branch analysis from position: 23
Branch analysis from position: 13
Branch analysis from position: 30
2 jumps found. (Code = 77) Position 1 = 32, Position 2 = 58
Branch analysis from position: 32
2 jumps found. (Code = 78) Position 1 = 33, Position 2 = 58
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 49
Branch analysis from position: 49
2 jumps found. (Code = 44) Position 1 = 51, Position 2 = 42
Branch analysis from position: 51
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
Branch analysis from position: 42
2 jumps found. (Code = 44) Position 1 = 51, Position 2 = 42
Branch analysis from position: 51
Branch analysis from position: 42
Branch analysis from position: 58
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 58
Branch analysis from position: 30
filename:       /in/Q3NBn
function name:  (null)
number of ops:  63
compiled vars:  !0 = $haystack, !1 = $needles, !2 = $needle, !3 = $times, !4 = $i, !5 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, 'abcdefghijklmnopqrstuvwxyz'
    3     1        ASSIGN                                                   !1, <array>
    4     2      > FE_RESET_R                                       $8      !1, ->30
          3    > > FE_FETCH_R                                               $8, !2, ->30
    5     4    >   INIT_FCALL                                               'microtime'
          5        SEND_VAL                                                 <true>
          6        DO_ICALL                                         $11     
          7        MUL                                              ~12     $11, -1
          8        FETCH_DIM_W                                      $9      !3, 'strncmp'
          9        ASSIGN_DIM                                               $9, !2
         10        OP_DATA                                                  ~12
    6    11        ASSIGN                                                   !4, 0
         12      > JMP                                                      ->21
    7    13    >   INIT_FCALL                                               'strncmp'
         14        SEND_VAR                                                 !0
         15        SEND_VAR                                                 !2
         16        SEND_VAL                                                 3
         17        DO_ICALL                                         $14     
         18        IS_IDENTICAL                                     ~15     $14, 0
         19        ASSIGN                                                   !5, ~15
    6    20        PRE_INC                                                  !4
         21    >   IS_SMALLER                                               !4, 1000000
         22      > JMPNZ                                                    ~18, ->13
    9    23    >   INIT_FCALL                                               'microtime'
         24        SEND_VAL                                                 <true>
         25        DO_ICALL                                         $21     
         26        FETCH_DIM_RW                                     $19     !3, 'strncmp'
         27        ASSIGN_DIM_OP                +=               1          $19, !2
         28        OP_DATA                                                  $21
    4    29      > JMP                                                      ->3
         30    >   FE_FREE                                                  $8
   11    31      > FE_RESET_R                                       $22     !1, ->58
         32    > > FE_FETCH_R                                               $22, !2, ->58
   12    33    >   INIT_FCALL                                               'microtime'
         34        SEND_VAL                                                 <true>
         35        DO_ICALL                                         $25     
         36        MUL                                              ~26     $25, -1
         37        FETCH_DIM_W                                      $23     !3, 'strpos'
         38        ASSIGN_DIM                                               $23, !2
         39        OP_DATA                                                  ~26
   13    40        ASSIGN                                                   !4, 0
         41      > JMP                                                      ->49
   14    42    >   INIT_FCALL                                               'strpos'
         43        SEND_VAR                                                 !0
         44        SEND_VAR                                                 !2
         45        DO_ICALL                                         $28     
         46        IS_IDENTICAL                                     ~29     $28, 0
         47        ASSIGN                                                   !5, ~29
   13    48        PRE_INC                                                  !4
         49    >   IS_SMALLER                                               !4, 1000000
         50      > JMPNZ                                                    ~32, ->42
   16    51    >   INIT_FCALL                                               'microtime'
         52        SEND_VAL                                                 <true>
         53        DO_ICALL                                         $35     
         54        FETCH_DIM_RW                                     $33     !3, 'strpos'
         55        ASSIGN_DIM_OP                +=               1          $33, !2
         56        OP_DATA                                                  $35
   11    57      > JMP                                                      ->32
         58    >   FE_FREE                                                  $22
   18    59        INIT_FCALL                                               'var_export'
         60        SEND_VAR                                                 !3
         61        DO_ICALL                                                 
         62      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
265.99 ms | 1405 KiB | 22 Q