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

Function camelcasecurrent:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/RPLHA
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/RPLHA
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:
153 ms | 1398 KiB | 25 Q