3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* ########################################################################## # PHP Benchmark Performance Script # # © 2010 Code24 BV # # # # Author : Alessandro Torrisi # # Company : Code24 BV, The Netherlands # # Date : July 31, 2010 # # version : 1.0 # # License : Creative Commons CC-BY license # # Website : http://www.php-benchmark-script.com # # # ########################################################################## */ function test_Math($count = 1400) { $time_start = microtime(true); $mathFunctions = array("abs", "acos", "asin", "atan", "bindec", "floor", "exp", "sin", "tan", "pi", "is_finite", "is_nan", "sqrt"); foreach ($mathFunctions as $key => $function) { if (!function_exists($function)) unset($mathFunctions[$key]); } for ($i=0; $i < $count; $i++) { foreach ($mathFunctions as $function) { $r = call_user_func_array($function, array($i)); } } return number_format(microtime(true) - $time_start, 3); } function test_StringManipulation($count = 1300) { $time_start = microtime(true); $stringFunctions = array("addslashes", "chunk_split", "metaphone", "strip_tags", "md5", "sha1", "strtoupper", "strtolower", "strrev", "strlen", "soundex", "ord"); foreach ($stringFunctions as $key => $function) { if (!function_exists($function)) unset($stringFunctions[$key]); } $string = "the quick brown fox jumps over the lazy dog"; for ($i=0; $i < $count; $i++) { foreach ($stringFunctions as $function) { $r = call_user_func_array($function, array($string)); } } return number_format(microtime(true) - $time_start, 3); } function test_Loops($count = 190000) { $time_start = microtime(true); for($i = 0; $i < $count; ++$i); $i = 0; while($i < $count) ++$i; return number_format(microtime(true) - $time_start, 3); } function test_IfElse($count = 90000) { $time_start = microtime(true); for ($i=0; $i < $count; $i++) { if ($i == -1) { } elseif ($i == -2) { } else if ($i == -3) { } } return number_format(microtime(true) - $time_start, 3); } $total = 0; $functions = get_defined_functions(); $line = str_pad("-",38,"-"); echo "<pre>$line\n|".str_pad("PHP BENCHMARK SCRIPT",36," ",STR_PAD_BOTH)."|\n$line\nStart : ".date("Y-m-d H:i:s")."\nServer : {$_SERVER['SERVER_NAME']}@{$_SERVER['SERVER_ADDR']}\nPHP version : ".PHP_VERSION."\nPlatform : ".PHP_OS. "\n$line\n"; foreach ($functions['user'] as $user) { if (preg_match('/^test_/', $user)) { $total += $result = $user(); echo str_pad($user, 25) . " : " . $result ." sec.\n"; } } echo str_pad("-", 38, "-") . "\n" . str_pad("Total time:", 25) . " : " . $total ." sec.</pre>"; ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 48, Position 2 = 67
Branch analysis from position: 48
2 jumps found. (Code = 78) Position 1 = 49, Position 2 = 67
Branch analysis from position: 49
2 jumps found. (Code = 43) Position 1 = 54, Position 2 = 66
Branch analysis from position: 54
1 jumps found. (Code = 42) Position 1 = 48
Branch analysis from position: 48
Branch analysis from position: 66
Branch analysis from position: 67
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 67
filename:       /in/9fYrA
function name:  (null)
number of ops:  84
compiled vars:  !0 = $total, !1 = $functions, !2 = $line, !3 = $user, !4 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   68     0  E >   ASSIGN                                                   !0, 0
   69     1        INIT_FCALL                                               'get_defined_functions'
          2        DO_ICALL                                         $6      
          3        ASSIGN                                                   !1, $6
   70     4        INIT_FCALL                                               'str_pad'
          5        SEND_VAL                                                 '-'
          6        SEND_VAL                                                 38
          7        SEND_VAL                                                 '-'
          8        DO_ICALL                                         $8      
          9        ASSIGN                                                   !2, $8
   71    10        ROPE_INIT                                     3  ~11     '%3Cpre%3E'
         11        ROPE_ADD                                      1  ~11     ~11, !2
         12        ROPE_END                                      2  ~10     ~11, '%0A%7C'
         13        INIT_FCALL                                               'str_pad'
         14        SEND_VAL                                                 'PHP+BENCHMARK+SCRIPT'
         15        SEND_VAL                                                 36
         16        SEND_VAL                                                 '+'
         17        SEND_VAL                                                 2
         18        DO_ICALL                                         $13     
         19        CONCAT                                           ~14     ~10, $13
         20        ROPE_INIT                                     3  ~16     '%7C%0A'
         21        ROPE_ADD                                      1  ~16     ~16, !2
         22        ROPE_END                                      2  ~15     ~16, '%0AStart+%3A+'
         23        CONCAT                                           ~18     ~14, ~15
         24        INIT_FCALL                                               'date'
         25        SEND_VAL                                                 'Y-m-d+H%3Ai%3As'
         26        DO_ICALL                                         $19     
         27        CONCAT                                           ~20     ~18, $19
         28        ROPE_INIT                                     5  ~26     '%0AServer+%3A+'
         29        FETCH_R                      global              ~21     '_SERVER'
         30        FETCH_DIM_R                                      ~22     ~21, 'SERVER_NAME'
         31        ROPE_ADD                                      1  ~26     ~26, ~22
         32        ROPE_ADD                                      2  ~26     ~26, '%40'
         33        FETCH_R                      global              ~23     '_SERVER'
         34        FETCH_DIM_R                                      ~24     ~23, 'SERVER_ADDR'
         35        ROPE_ADD                                      3  ~26     ~26, ~24
         36        ROPE_END                                      4  ~25     ~26, '%0APHP+version+%3A+'
         37        CONCAT                                           ~29     ~20, ~25
         38        CONCAT                                           ~30     ~29, '8.0.0'
         39        CONCAT                                           ~31     ~30, '%0APlatform+%3A+'
         40        CONCAT                                           ~32     ~31, 'Linux'
         41        ROPE_INIT                                     3  ~34     '%0A'
         42        ROPE_ADD                                      1  ~34     ~34, !2
         43        ROPE_END                                      2  ~33     ~34, '%0A'
         44        CONCAT                                           ~36     ~32, ~33
         45        ECHO                                                     ~36
   72    46        FETCH_DIM_R                                      ~37     !1, 'user'
         47      > FE_RESET_R                                       $38     ~37, ->67
         48    > > FE_FETCH_R                                               $38, !3, ->67
   73    49    >   INIT_FCALL                                               'preg_match'
         50        SEND_VAL                                                 '%2F%5Etest_%2F'
         51        SEND_VAR                                                 !3
         52        DO_ICALL                                         $39     
         53      > JMPZ                                                     $39, ->66
   74    54    >   INIT_DYNAMIC_CALL                                        !3
         55        DO_FCALL                                      0  $40     
         56        ASSIGN                                           ~41     !4, $40
         57        ASSIGN_OP                                     1          !0, ~41
   75    58        INIT_FCALL                                               'str_pad'
         59        SEND_VAR                                                 !3
         60        SEND_VAL                                                 25
         61        DO_ICALL                                         $43     
         62        CONCAT                                           ~44     $43, '+%3A+'
         63        CONCAT                                           ~45     ~44, !4
         64        CONCAT                                           ~46     ~45, '+sec.%0A'
         65        ECHO                                                     ~46
   72    66    > > JMP                                                      ->48
         67    >   FE_FREE                                                  $38
   78    68        INIT_FCALL                                               'str_pad'
         69        SEND_VAL                                                 '-'
         70        SEND_VAL                                                 38
         71        SEND_VAL                                                 '-'
         72        DO_ICALL                                         $47     
         73        CONCAT                                           ~48     $47, '%0A'
         74        INIT_FCALL                                               'str_pad'
         75        SEND_VAL                                                 'Total+time%3A'
         76        SEND_VAL                                                 25
         77        DO_ICALL                                         $49     
         78        CONCAT                                           ~50     ~48, $49
         79        CONCAT                                           ~51     ~50, '+%3A+'
         80        CONCAT                                           ~52     ~51, !0
         81        CONCAT                                           ~53     ~52, '+sec.%3C%2Fpre%3E'
         82        ECHO                                                     ~53
   80    83      > RETURN                                                   1

Function test_math:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 16
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 16
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 15
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 15
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
2 jumps found. (Code = 44) Position 1 = 32, Position 2 = 19
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
2 jumps found. (Code = 77) Position 1 = 20, Position 2 = 28
Branch analysis from position: 20
2 jumps found. (Code = 78) Position 1 = 21, Position 2 = 28
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
Branch analysis from position: 28
2 jumps found. (Code = 44) Position 1 = 32, Position 2 = 19
Branch analysis from position: 32
Branch analysis from position: 19
Branch analysis from position: 28
Branch analysis from position: 16
filename:       /in/9fYrA
function name:  test_Math
number of ops:  42
compiled vars:  !0 = $count, !1 = $time_start, !2 = $mathFunctions, !3 = $function, !4 = $key, !5 = $i, !6 = $r
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV_INIT                                        !0      1400
   18     1        INIT_FCALL                                               'microtime'
          2        SEND_VAL                                                 <true>
          3        DO_ICALL                                         $7      
          4        ASSIGN                                                   !1, $7
   19     5        ASSIGN                                                   !2, <array>
   20     6      > FE_RESET_R                                       $10     !2, ->16
          7    > > FE_FETCH_R                                       ~11     $10, !3, ->16
          8    >   ASSIGN                                                   !4, ~11
   21     9        INIT_FCALL                                               'function_exists'
         10        SEND_VAR                                                 !3
         11        DO_ICALL                                         $13     
         12        BOOL_NOT                                         ~14     $13
         13      > JMPZ                                                     ~14, ->15
         14    >   UNSET_DIM                                                !2, !4
   20    15    > > JMP                                                      ->7
         16    >   FE_FREE                                                  $10
   23    17        ASSIGN                                                   !5, 0
         18      > JMP                                                      ->30
   24    19    > > FE_RESET_R                                       $16     !2, ->28
         20    > > FE_FETCH_R                                               $16, !3, ->28
   25    21    >   INIT_USER_CALL                                0          'call_user_func_array', !3
         22        INIT_ARRAY                                       ~17     !5
         23        SEND_ARRAY                                               ~17
         24        CHECK_UNDEF_ARGS                                         
         25        DO_FCALL                                      0  $18     
         26        ASSIGN                                                   !6, $18
   24    27      > JMP                                                      ->20
         28    >   FE_FREE                                                  $16
   23    29        PRE_INC                                                  !5
         30    >   IS_SMALLER                                               !5, !0
         31      > JMPNZ                                                    ~21, ->19
   28    32    >   INIT_FCALL                                               'number_format'
         33        INIT_FCALL                                               'microtime'
         34        SEND_VAL                                                 <true>
         35        DO_ICALL                                         $22     
         36        SUB                                              ~23     $22, !1
         37        SEND_VAL                                                 ~23
         38        SEND_VAL                                                 3
         39        DO_ICALL                                         $24     
         40      > RETURN                                                   $24
   29    41*     > RETURN                                                   null

End of function test_math

Function test_stringmanipulation:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 16
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 16
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 15
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 15
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
2 jumps found. (Code = 44) Position 1 = 33, Position 2 = 20
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
2 jumps found. (Code = 77) Position 1 = 21, Position 2 = 29
Branch analysis from position: 21
2 jumps found. (Code = 78) Position 1 = 22, Position 2 = 29
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
Branch analysis from position: 29
2 jumps found. (Code = 44) Position 1 = 33, Position 2 = 20
Branch analysis from position: 33
Branch analysis from position: 20
Branch analysis from position: 29
Branch analysis from position: 16
filename:       /in/9fYrA
function name:  test_StringManipulation
number of ops:  43
compiled vars:  !0 = $count, !1 = $time_start, !2 = $stringFunctions, !3 = $function, !4 = $key, !5 = $string, !6 = $i, !7 = $r
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   RECV_INIT                                        !0      1300
   33     1        INIT_FCALL                                               'microtime'
          2        SEND_VAL                                                 <true>
          3        DO_ICALL                                         $8      
          4        ASSIGN                                                   !1, $8
   34     5        ASSIGN                                                   !2, <array>
   35     6      > FE_RESET_R                                       $11     !2, ->16
          7    > > FE_FETCH_R                                       ~12     $11, !3, ->16
          8    >   ASSIGN                                                   !4, ~12
   36     9        INIT_FCALL                                               'function_exists'
         10        SEND_VAR                                                 !3
         11        DO_ICALL                                         $14     
         12        BOOL_NOT                                         ~15     $14
         13      > JMPZ                                                     ~15, ->15
         14    >   UNSET_DIM                                                !2, !4
   35    15    > > JMP                                                      ->7
         16    >   FE_FREE                                                  $11
   38    17        ASSIGN                                                   !5, 'the+quick+brown+fox+jumps+over+the+lazy+dog'
   39    18        ASSIGN                                                   !6, 0
         19      > JMP                                                      ->31
   40    20    > > FE_RESET_R                                       $18     !2, ->29
         21    > > FE_FETCH_R                                               $18, !3, ->29
   41    22    >   INIT_USER_CALL                                0          'call_user_func_array', !3
         23        INIT_ARRAY                                       ~19     !5
         24        SEND_ARRAY                                               ~19
         25        CHECK_UNDEF_ARGS                                         
         26        DO_FCALL                                      0  $20     
         27        ASSIGN                                                   !7, $20
   40    28      > JMP                                                      ->21
         29    >   FE_FREE                                                  $18
   39    30        PRE_INC                                                  !6
         31    >   IS_SMALLER                                               !6, !0
         32      > JMPNZ                                                    ~23, ->20
   44    33    >   INIT_FCALL                                               'number_format'
         34        INIT_FCALL                                               'microtime'
         35        SEND_VAL                                                 <true>
         36        DO_ICALL                                         $24     
         37        SUB                                              ~25     $24, !1
         38        SEND_VAL                                                 ~25
         39        SEND_VAL                                                 3
         40        DO_ICALL                                         $26     
         41      > RETURN                                                   $26
   45    42*     > RETURN                                                   null

End of function test_stringmanipulation

Function test_loops:
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 = 7
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
2 jumps found. (Code = 44) Position 1 = 15, Position 2 = 12
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
2 jumps found. (Code = 44) Position 1 = 15, Position 2 = 12
Branch analysis from position: 15
Branch analysis from position: 12
Branch analysis from position: 7
2 jumps found. (Code = 44) Position 1 = 10, Position 2 = 7
Branch analysis from position: 10
Branch analysis from position: 7
filename:       /in/9fYrA
function name:  test_Loops
number of ops:  25
compiled vars:  !0 = $count, !1 = $time_start, !2 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   48     0  E >   RECV_INIT                                        !0      190000
   49     1        INIT_FCALL                                               'microtime'
          2        SEND_VAL                                                 <true>
          3        DO_ICALL                                         $3      
          4        ASSIGN                                                   !1, $3
   50     5        ASSIGN                                                   !2, 0
          6      > JMP                                                      ->8
          7    >   PRE_INC                                                  !2
          8    >   IS_SMALLER                                               !2, !0
          9      > JMPNZ                                                    ~7, ->7
   51    10    >   ASSIGN                                                   !2, 0
         11      > JMP                                                      ->13
         12    >   PRE_INC                                                  !2
         13    >   IS_SMALLER                                               !2, !0
         14      > JMPNZ                                                    ~10, ->12
   52    15    >   INIT_FCALL                                               'number_format'
         16        INIT_FCALL                                               'microtime'
         17        SEND_VAL                                                 <true>
         18        DO_ICALL                                         $11     
         19        SUB                                              ~12     $11, !1
         20        SEND_VAL                                                 ~12
         21        SEND_VAL                                                 3
         22        DO_ICALL                                         $13     
         23      > RETURN                                                   $13
   53    24*     > RETURN                                                   null

End of function test_loops

Function test_ifelse:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 7
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 10
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 7
Branch analysis from position: 18
Branch analysis from position: 7
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 13
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 15
Branch analysis from position: 15
Branch analysis from position: 15
filename:       /in/9fYrA
function name:  test_IfElse
number of ops:  28
compiled vars:  !0 = $count, !1 = $time_start, !2 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   56     0  E >   RECV_INIT                                        !0      90000
   57     1        INIT_FCALL                                               'microtime'
          2        SEND_VAL                                                 <true>
          3        DO_ICALL                                         $3      
          4        ASSIGN                                                   !1, $3
   58     5        ASSIGN                                                   !2, 0
          6      > JMP                                                      ->16
   59     7    >   IS_EQUAL                                                 !2, -1
          8      > JMPZ                                                     ~6, ->10
          9    > > JMP                                                      ->15
   60    10    >   IS_EQUAL                                                 !2, -2
         11      > JMPZ                                                     ~7, ->13
         12    > > JMP                                                      ->15
   61    13    >   IS_EQUAL                                                 !2, -3
         14      > JMPZ                                                     ~8, ->15
   58    15    >   PRE_INC                                                  !2
         16    >   IS_SMALLER                                               !2, !0
         17      > JMPNZ                                                    ~10, ->7
   64    18    >   INIT_FCALL                                               'number_format'
         19        INIT_FCALL                                               'microtime'
         20        SEND_VAL                                                 <true>
         21        DO_ICALL                                         $11     
         22        SUB                                              ~12     $11, !1
         23        SEND_VAL                                                 ~12
         24        SEND_VAL                                                 3
         25        DO_ICALL                                         $13     
         26      > RETURN                                                   $13
   65    27*     > RETURN                                                   null

End of function test_ifelse

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.01 ms | 1424 KiB | 28 Q