3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Setup $count = 1000; function camelcaseCurrent($file) { $r1 = ucwords(str_replace(array('_', '-', '/'), ' ', $file)); $r2 = str_replace(' ', '', $r1); return $r2; } function camelcaseNew($file) { $file = str_replace('_', ' ', $file); $file = str_replace('-', ' ', $file); $file = str_replace('/', ' ', $file); $r1 = ucwords(file); $r2 = str_replace(' ', '', $r1); return $r2; } // Warm up for($i = 0; $i < $count; $i++) { camelcaseCurrent('asset_library'); camelcaseNew('asset_library'); } // Test - current $t0 = microtime(true); for($i = 0; $i < $count; $i++) { camelcaseCurrent('asset_library'); } $deltaCurrent = microtime(true) - $t0; // Test - new $t0 = microtime(true); for($i = 0; $i < $count; $i++) { camelcaseNew('asset_library'); } $deltaNew = microtime(true) - $t0; echo "case current: ", round($deltaCurrent * 1000, 2), " ms\n"; echo "case new: ", round($deltaNew * 1000, 2), " ms\n"; echo "new gain: ", round($deltaNew * 100 / $deltaCurrent - 100, 2), " %\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
2 jumps found. (Code = 44) Position 1 = 12, Position 2 = 3
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
2 jumps found. (Code = 44) Position 1 = 24, Position 2 = 18
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
2 jumps found. (Code = 44) Position 1 = 41, Position 2 = 35
Branch analysis from position: 41
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 35
2 jumps found. (Code = 44) Position 1 = 41, Position 2 = 35
Branch analysis from position: 41
Branch analysis from position: 35
Branch analysis from position: 18
2 jumps found. (Code = 44) Position 1 = 24, Position 2 = 18
Branch analysis from position: 24
Branch analysis from position: 18
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 12, Position 2 = 3
Branch analysis from position: 12
Branch analysis from position: 3
filename:       /in/LlK6o
function name:  (null)
number of ops:  73
compiled vars:  !0 = $count, !1 = $i, !2 = $t0, !3 = $deltaCurrent, !4 = $deltaNew
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 1000
   21     1        ASSIGN                                                   !1, 0
          2      > JMP                                                      ->10
   22     3    >   INIT_FCALL                                               'camelcasecurrent'
          4        SEND_VAL                                                 'asset_library'
          5        DO_FCALL                                      0          
   23     6        INIT_FCALL                                               'camelcasenew'
          7        SEND_VAL                                                 'asset_library'
          8        DO_FCALL                                      0          
   21     9        PRE_INC                                                  !1
         10    >   IS_SMALLER                                               !1, !0
         11      > JMPNZ                                                    ~10, ->3
   27    12    >   INIT_FCALL                                               'microtime'
         13        SEND_VAL                                                 <true>
         14        DO_ICALL                                         $11     
         15        ASSIGN                                                   !2, $11
   28    16        ASSIGN                                                   !1, 0
         17      > JMP                                                      ->22
   29    18    >   INIT_FCALL                                               'camelcasecurrent'
         19        SEND_VAL                                                 'asset_library'
         20        DO_FCALL                                      0          
   28    21        PRE_INC                                                  !1
         22    >   IS_SMALLER                                               !1, !0
         23      > JMPNZ                                                    ~16, ->18
   31    24    >   INIT_FCALL                                               'microtime'
         25        SEND_VAL                                                 <true>
         26        DO_ICALL                                         $17     
         27        SUB                                              ~18     $17, !2
         28        ASSIGN                                                   !3, ~18
   35    29        INIT_FCALL                                               'microtime'
         30        SEND_VAL                                                 <true>
         31        DO_ICALL                                         $20     
         32        ASSIGN                                                   !2, $20
   36    33        ASSIGN                                                   !1, 0
         34      > JMP                                                      ->39
   37    35    >   INIT_FCALL                                               'camelcasenew'
         36        SEND_VAL                                                 'asset_library'
         37        DO_FCALL                                      0          
   36    38        PRE_INC                                                  !1
         39    >   IS_SMALLER                                               !1, !0
         40      > JMPNZ                                                    ~25, ->35
   39    41    >   INIT_FCALL                                               'microtime'
         42        SEND_VAL                                                 <true>
         43        DO_ICALL                                         $26     
         44        SUB                                              ~27     $26, !2
         45        ASSIGN                                                   !4, ~27
   41    46        ECHO                                                     'case+current%3A+'
         47        INIT_FCALL                                               'round'
         48        MUL                                              ~29     !3, 1000
         49        SEND_VAL                                                 ~29
         50        SEND_VAL                                                 2
         51        DO_ICALL                                         $30     
         52        ECHO                                                     $30
         53        ECHO                                                     '+ms%0A'
   42    54        ECHO                                                     'case+new%3A+'
         55        INIT_FCALL                                               'round'
         56        MUL                                              ~31     !4, 1000
         57        SEND_VAL                                                 ~31
         58        SEND_VAL                                                 2
         59        DO_ICALL                                         $32     
         60        ECHO                                                     $32
         61        ECHO                                                     '+ms%0A'
   43    62        ECHO                                                     'new+gain%3A+'
         63        INIT_FCALL                                               'round'
         64        MUL                                              ~33     !4, 100
         65        DIV                                              ~34     ~33, !3
         66        SUB                                              ~35     ~34, 100
         67        SEND_VAL                                                 ~35
         68        SEND_VAL                                                 2
         69        DO_ICALL                                         $36     
         70        ECHO                                                     $36
         71        ECHO                                                     '+%25%0A'
         72      > RETURN                                                   1

Function camelcasecurrent:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LlK6o
function name:  camelcaseCurrent
number of ops:  18
compiled vars:  !0 = $file, !1 = $r1, !2 = $r2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    6     1        INIT_FCALL                                               'ucwords'
          2        INIT_FCALL                                               'str_replace'
          3        SEND_VAL                                                 <array>
          4        SEND_VAL                                                 '+'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $3      
          7        SEND_VAR                                                 $3
          8        DO_ICALL                                         $4      
          9        ASSIGN                                                   !1, $4
    7    10        INIT_FCALL                                               'str_replace'
         11        SEND_VAL                                                 '+'
         12        SEND_VAL                                                 ''
         13        SEND_VAR                                                 !1
         14        DO_ICALL                                         $6      
         15        ASSIGN                                                   !2, $6
    8    16      > RETURN                                                   !2
    9    17*     > RETURN                                                   null

End of function camelcasecurrent

Function camelcasenew:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LlK6o
function name:  camelcaseNew
number of ops:  32
compiled vars:  !0 = $file, !1 = $r1, !2 = $r2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
   12     1        INIT_FCALL                                               'str_replace'
          2        SEND_VAL                                                 '_'
          3        SEND_VAL                                                 '+'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $3      
          6        ASSIGN                                                   !0, $3
   13     7        INIT_FCALL                                               'str_replace'
          8        SEND_VAL                                                 '-'
          9        SEND_VAL                                                 '+'
         10        SEND_VAR                                                 !0
         11        DO_ICALL                                         $5      
         12        ASSIGN                                                   !0, $5
   14    13        INIT_FCALL                                               'str_replace'
         14        SEND_VAL                                                 '%2F'
         15        SEND_VAL                                                 '+'
         16        SEND_VAR                                                 !0
         17        DO_ICALL                                         $7      
         18        ASSIGN                                                   !0, $7
   15    19        INIT_FCALL                                               'ucwords'
         20        FETCH_CONSTANT                                   ~9      'file'
         21        SEND_VAL                                                 ~9
         22        DO_ICALL                                         $10     
         23        ASSIGN                                                   !1, $10
   16    24        INIT_FCALL                                               'str_replace'
         25        SEND_VAL                                                 '+'
         26        SEND_VAL                                                 ''
         27        SEND_VAR                                                 !1
         28        DO_ICALL                                         $12     
         29        ASSIGN                                                   !2, $12
   17    30      > RETURN                                                   !2
   18    31*     > RETURN                                                   null

End of function camelcasenew

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.66 ms | 1402 KiB | 25 Q