3v4l.org

run code in 300+ PHP versions simultaneously
<?php define('TEST_LOOPS', 10); define('TEST_STRING', str_repeat('English+日に本ほん語ご', 16000)); //define('TEST_STRING', str_repeat('English', 16000)); //define('TEST_STRING', str_repeat('日に本ほん語ご', 16000)); error_reporting(-1); mb_internal_encoding('UTF-8'); function test($label, $callback) { $time = microtime(true); for ($i = 0; $i < TEST_LOOPS; $i++) { $callback(); } $duration = microtime(true) - $time; echo "{$label}: {$duration}s\n"; } test('preg_split+count', function() { $chars = preg_split('//u', TEST_STRING, -1, PREG_SPLIT_NO_EMPTY); $len = count($chars); for ($i = 0; $i < $len; $i++) { $char = $chars[$i]; // use $char } }); test('preg_split+foreach', function() { $chars = preg_split('//u', TEST_STRING, -1, PREG_SPLIT_NO_EMPTY); foreach ($chars as $char) { // use $char } }); test('preg_match_all', function() { if (preg_match_all('/./u', TEST_STRING, $matches)) { foreach ($matches[0] as $char) { // use $char } } });
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DZgrc
function name:  (null)
number of ops:  34
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'define'
          1        SEND_VAL                                                 'TEST_LOOPS'
          2        SEND_VAL                                                 10
          3        DO_ICALL                                                 
    4     4        INIT_FCALL                                               'define'
          5        SEND_VAL                                                 'TEST_STRING'
          6        INIT_FCALL                                               'str_repeat'
          7        SEND_VAL                                                 'English%2B%E6%97%A5%E3%81%AB%E6%9C%AC%E3%81%BB%E3%82%93%E8%AA%9E%E3%81%94'
          8        SEND_VAL                                                 16000
          9        DO_ICALL                                         $1      
         10        SEND_VAR                                                 $1
         11        DO_ICALL                                                 
    8    12        INIT_FCALL                                               'error_reporting'
         13        SEND_VAL                                                 -1
         14        DO_ICALL                                                 
    9    15        INIT_FCALL                                               'mb_internal_encoding'
         16        SEND_VAL                                                 'UTF-8'
         17        DO_ICALL                                                 
   23    18        INIT_FCALL                                               'test'
         19        SEND_VAL                                                 'preg_split%2Bcount'
         20        DECLARE_LAMBDA_FUNCTION                          ~5      [0]
   30    21        SEND_VAL                                                 ~5
   23    22        DO_FCALL                                      0          
   32    23        INIT_FCALL                                               'test'
         24        SEND_VAL                                                 'preg_split%2Bforeach'
         25        DECLARE_LAMBDA_FUNCTION                          ~7      [1]
   37    26        SEND_VAL                                                 ~7
   32    27        DO_FCALL                                      0          
   39    28        INIT_FCALL                                               'test'
         29        SEND_VAL                                                 'preg_match_all'
         30        DECLARE_LAMBDA_FUNCTION                          ~9      [2]
   45    31        SEND_VAL                                                 ~9
   39    32        DO_FCALL                                      0          
   45    33      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
2 jumps found. (Code = 44) Position 1 = 17, Position 2 = 12
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
2 jumps found. (Code = 44) Position 1 = 17, Position 2 = 12
Branch analysis from position: 17
Branch analysis from position: 12
filename:       /in/DZgrc
function name:  {closure}
number of ops:  18
compiled vars:  !0 = $chars, !1 = $len, !2 = $i, !3 = $char
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   INIT_FCALL                                               'preg_split'
          1        SEND_VAL                                                 '%2F%2Fu'
          2        FETCH_CONSTANT                                   ~4      'TEST_STRING'
          3        SEND_VAL                                                 ~4
          4        SEND_VAL                                                 -1
          5        SEND_VAL                                                 1
          6        DO_ICALL                                         $5      
          7        ASSIGN                                                   !0, $5
   25     8        COUNT                                            ~7      !0
          9        ASSIGN                                                   !1, ~7
   26    10        ASSIGN                                                   !2, 0
         11      > JMP                                                      ->15
   27    12    >   FETCH_DIM_R                                      ~10     !0, !2
         13        ASSIGN                                                   !3, ~10
   26    14        PRE_INC                                                  !2
         15    >   IS_SMALLER                                               !2, !1
         16      > JMPNZ                                                    ~13, ->12
   30    17    > > RETURN                                                   null

End of Dynamic Function 0

Dynamic Function 1
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 11
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 11
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/DZgrc
function name:  {closure}
number of ops:  13
compiled vars:  !0 = $chars, !1 = $char
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   INIT_FCALL                                               'preg_split'
          1        SEND_VAL                                                 '%2F%2Fu'
          2        FETCH_CONSTANT                                   ~2      'TEST_STRING'
          3        SEND_VAL                                                 ~2
          4        SEND_VAL                                                 -1
          5        SEND_VAL                                                 1
          6        DO_ICALL                                         $3      
          7        ASSIGN                                                   !0, $3
   34     8      > FE_RESET_R                                       $5      !0, ->11
          9    > > FE_FETCH_R                                               $5, !1, ->11
         10    > > JMP                                                      ->9
         11    >   FE_FREE                                                  $5
   37    12      > RETURN                                                   null

End of Dynamic Function 1

Dynamic Function 2
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 12
Branch analysis from position: 7
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 11
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 11
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
Branch analysis from position: 12
filename:       /in/DZgrc
function name:  {closure}
number of ops:  13
compiled vars:  !0 = $matches, !1 = $char
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   40     0  E >   INIT_FCALL                                               'preg_match_all'
          1        SEND_VAL                                                 '%2F.%2Fu'
          2        FETCH_CONSTANT                                   ~2      'TEST_STRING'
          3        SEND_VAL                                                 ~2
          4        SEND_REF                                                 !0
          5        DO_ICALL                                         $3      
          6      > JMPZ                                                     $3, ->12
   41     7    >   FETCH_DIM_R                                      ~4      !0, 0
          8      > FE_RESET_R                                       $5      ~4, ->11
          9    > > FE_FETCH_R                                               $5, !1, ->11
         10    > > JMP                                                      ->9
         11    >   FE_FREE                                                  $5
   45    12    > > RETURN                                                   null

End of Dynamic Function 2

Function test:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 8
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 8
Branch analysis from position: 14
Branch analysis from position: 8
filename:       /in/DZgrc
function name:  test
number of ops:  25
compiled vars:  !0 = $label, !1 = $callback, !2 = $time, !3 = $i, !4 = $duration
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   14     2        INIT_FCALL                                               'microtime'
          3        SEND_VAL                                                 <true>
          4        DO_ICALL                                         $5      
          5        ASSIGN                                                   !2, $5
   15     6        ASSIGN                                                   !3, 0
          7      > JMP                                                      ->11
   16     8    >   INIT_DYNAMIC_CALL                                        !1
          9        DO_FCALL                                      0          
   15    10        PRE_INC                                                  !3
         11    >   FETCH_CONSTANT                                   ~10     'TEST_LOOPS'
         12        IS_SMALLER                                               !3, ~10
         13      > JMPNZ                                                    ~11, ->8
   19    14    >   INIT_FCALL                                               'microtime'
         15        SEND_VAL                                                 <true>
         16        DO_ICALL                                         $12     
         17        SUB                                              ~13     $12, !2
         18        ASSIGN                                                   !4, ~13
   20    19        ROPE_INIT                                     4  ~16     !0
         20        ROPE_ADD                                      1  ~16     ~16, '%3A+'
         21        ROPE_ADD                                      2  ~16     ~16, !4
         22        ROPE_END                                      3  ~15     ~16, 's%0A'
         23        ECHO                                                     ~15
   21    24      > RETURN                                                   null

End of function test

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
140.31 ms | 1015 KiB | 23 Q