3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace foo; const N = 100_000_000; function without_backslash() { $start = \hrtime(true); $tmp = []; for($i = 0; $i < 10000; $i++) { $tmp[] = strtoupper("test" . $i); } $stop = \hrtime(true); \printf("Without backslash: %f s\n", ($stop - $start)/1e9); } function with_backslash() { $start = \hrtime(true); $tmp = []; for($i = 0; $i < 10000; $i++) { $tmp[] = \strtoupper("test" . $i); } $stop = \hrtime(true); \printf("With backslash: %f s\n", ($stop - $start)/1e9); } without_backslash(); with_backslash(); printf("\n"); without_backslash(); with_backslash(); printf("\n"); without_backslash(); with_backslash(); printf("\n"); without_backslash(); with_backslash(); printf("\n");
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eFcPk
function name:  (null)
number of ops:  30
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   DECLARE_CONST                                            'foo%5CN', 100000000
   28     1        INIT_NS_FCALL_BY_NAME                                    'foo%5Cwithout_backslash'
          2        DO_FCALL                                      0          
   29     3        INIT_NS_FCALL_BY_NAME                                    'foo%5Cwith_backslash'
          4        DO_FCALL                                      0          
   30     5        INIT_NS_FCALL_BY_NAME                                    'foo%5Cprintf'
          6        SEND_VAL_EX                                              '%0A'
          7        DO_FCALL                                      0          
   31     8        INIT_NS_FCALL_BY_NAME                                    'foo%5Cwithout_backslash'
          9        DO_FCALL                                      0          
   32    10        INIT_NS_FCALL_BY_NAME                                    'foo%5Cwith_backslash'
         11        DO_FCALL                                      0          
   33    12        INIT_NS_FCALL_BY_NAME                                    'foo%5Cprintf'
         13        SEND_VAL_EX                                              '%0A'
         14        DO_FCALL                                      0          
   34    15        INIT_NS_FCALL_BY_NAME                                    'foo%5Cwithout_backslash'
         16        DO_FCALL                                      0          
   35    17        INIT_NS_FCALL_BY_NAME                                    'foo%5Cwith_backslash'
         18        DO_FCALL                                      0          
   36    19        INIT_NS_FCALL_BY_NAME                                    'foo%5Cprintf'
         20        SEND_VAL_EX                                              '%0A'
         21        DO_FCALL                                      0          
   37    22        INIT_NS_FCALL_BY_NAME                                    'foo%5Cwithout_backslash'
         23        DO_FCALL                                      0          
   38    24        INIT_NS_FCALL_BY_NAME                                    'foo%5Cwith_backslash'
         25        DO_FCALL                                      0          
   39    26        INIT_NS_FCALL_BY_NAME                                    'foo%5Cprintf'
         27        SEND_VAL_EX                                              '%0A'
         28        DO_FCALL                                      0          
         29      > RETURN                                                   1

Function foo%5Cwithout_backslash:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
2 jumps found. (Code = 44) Position 1 = 16, Position 2 = 7
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 44) Position 1 = 16, Position 2 = 7
Branch analysis from position: 16
Branch analysis from position: 7
filename:       /in/eFcPk
function name:  foo\without_backslash
number of ops:  27
compiled vars:  !0 = $start, !1 = $tmp, !2 = $i, !3 = $stop
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   INIT_FCALL                                               'hrtime'
          1        SEND_VAL                                                 <true>
          2        DO_ICALL                                         $4      
          3        ASSIGN                                                   !0, $4
    9     4        ASSIGN                                                   !1, <array>
   10     5        ASSIGN                                                   !2, 0
          6      > JMP                                                      ->14
   11     7    >   INIT_NS_FCALL_BY_NAME                                    'foo%5Cstrtoupper'
          8        CONCAT                                           ~9      'test', !2
          9        SEND_VAL_EX                                              ~9
         10        DO_FCALL                                      0  $10     
         11        ASSIGN_DIM                                               !1
         12        OP_DATA                                                  $10
   10    13        PRE_INC                                                  !2
         14    >   IS_SMALLER                                               !2, 10000
         15      > JMPNZ                                                    ~12, ->7
   13    16    >   INIT_FCALL                                               'hrtime'
         17        SEND_VAL                                                 <true>
         18        DO_ICALL                                         $13     
         19        ASSIGN                                                   !3, $13
   14    20        INIT_FCALL                                               'printf'
         21        SEND_VAL                                                 'Without+backslash%3A+%25f+s%0A'
         22        SUB                                              ~15     !3, !0
         23        DIV                                              ~16     ~15, 1.0e+9
         24        SEND_VAL                                                 ~16
         25        DO_ICALL                                                 
   15    26      > RETURN                                                   null

End of function foo%5Cwithout_backslash

Function foo%5Cwith_backslash:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
2 jumps found. (Code = 44) Position 1 = 16, Position 2 = 7
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 44) Position 1 = 16, Position 2 = 7
Branch analysis from position: 16
Branch analysis from position: 7
filename:       /in/eFcPk
function name:  foo\with_backslash
number of ops:  27
compiled vars:  !0 = $start, !1 = $tmp, !2 = $i, !3 = $stop
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   INIT_FCALL                                               'hrtime'
          1        SEND_VAL                                                 <true>
          2        DO_ICALL                                         $4      
          3        ASSIGN                                                   !0, $4
   19     4        ASSIGN                                                   !1, <array>
   20     5        ASSIGN                                                   !2, 0
          6      > JMP                                                      ->14
   21     7    >   INIT_FCALL                                               'strtoupper'
          8        CONCAT                                           ~9      'test', !2
          9        SEND_VAL                                                 ~9
         10        DO_ICALL                                         $10     
         11        ASSIGN_DIM                                               !1
         12        OP_DATA                                                  $10
   20    13        PRE_INC                                                  !2
         14    >   IS_SMALLER                                               !2, 10000
         15      > JMPNZ                                                    ~12, ->7
   23    16    >   INIT_FCALL                                               'hrtime'
         17        SEND_VAL                                                 <true>
         18        DO_ICALL                                         $13     
         19        ASSIGN                                                   !3, $13
   24    20        INIT_FCALL                                               'printf'
         21        SEND_VAL                                                 'With+backslash%3A+%25f+s%0A'
         22        SUB                                              ~15     !3, !0
         23        DIV                                              ~16     ~15, 1.0e+9
         24        SEND_VAL                                                 ~16
         25        DO_ICALL                                                 
   25    26      > RETURN                                                   null

End of function foo%5Cwith_backslash

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
137.03 ms | 1011 KiB | 24 Q