3v4l.org

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

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

End of function camelcasenew

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.71 ms | 1407 KiB | 25 Q