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) { $r1 = ucwords(str_replace(array('_', '-', '/'), '', $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/hUTbi
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
   18     1        ASSIGN                                                   !1, 0
          2      > JMP                                                      ->10
   19     3    >   INIT_FCALL                                               'camelcasecurrent'
          4        SEND_VAL                                                 'asset_library'
          5        DO_FCALL                                      0          
   20     6        INIT_FCALL                                               'camelcasenew'
          7        SEND_VAL                                                 'asset_library'
          8        DO_FCALL                                      0          
   18     9        PRE_INC                                                  !1
         10    >   IS_SMALLER                                               !1, !0
         11      > JMPNZ                                                    ~10, ->3
   24    12    >   INIT_FCALL                                               'microtime'
         13        SEND_VAL                                                 <true>
         14        DO_ICALL                                         $11     
         15        ASSIGN                                                   !2, $11
   25    16        ASSIGN                                                   !1, 0
         17      > JMP                                                      ->22
   26    18    >   INIT_FCALL                                               'camelcasecurrent'
         19        SEND_VAL                                                 'asset_library'
         20        DO_FCALL                                      0          
   25    21        PRE_INC                                                  !1
         22    >   IS_SMALLER                                               !1, !0
         23      > JMPNZ                                                    ~16, ->18
   28    24    >   INIT_FCALL                                               'microtime'
         25        SEND_VAL                                                 <true>
         26        DO_ICALL                                         $17     
         27        SUB                                              ~18     $17, !2
         28        ASSIGN                                                   !3, ~18
   32    29        INIT_FCALL                                               'microtime'
         30        SEND_VAL                                                 <true>
         31        DO_ICALL                                         $20     
         32        ASSIGN                                                   !2, $20
   33    33        ASSIGN                                                   !1, 0
         34      > JMP                                                      ->39
   34    35    >   INIT_FCALL                                               'camelcasenew'
         36        SEND_VAL                                                 'asset_library'
         37        DO_FCALL                                      0          
   33    38        PRE_INC                                                  !1
         39    >   IS_SMALLER                                               !1, !0
         40      > JMPNZ                                                    ~25, ->35
   36    41    >   INIT_FCALL                                               'microtime'
         42        SEND_VAL                                                 <true>
         43        DO_ICALL                                         $26     
         44        SUB                                              ~27     $26, !2
         45        ASSIGN                                                   !4, ~27
   38    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'
   39    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'
   40    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/hUTbi
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/hUTbi
function name:  camelcaseNew
number of ops:  18
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                                               '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
   13    10        INIT_FCALL                                               'str_replace'
         11        SEND_VAL                                                 '+'
         12        SEND_VAL                                                 ''
         13        SEND_VAR                                                 !1
         14        DO_ICALL                                         $6      
         15        ASSIGN                                                   !2, $6
   14    16      > RETURN                                                   !2
   15    17*     > RETURN                                                   null

End of function camelcasenew

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.99 ms | 1407 KiB | 25 Q