3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* ########################################################################## # PHP Benchmark Performance Script # # <A9> 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 # # # ########################################################################## */ set_time_limit(0); function get_microtime() { $time = microtime(true); if (is_string($time)) { list($f, $i) = explode(" ", $time); $time = intval($i) + floatval($f); } return $time; } function test_Math($count = 1400000) { $time_start = get_microtime(); $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(get_microtime() - $time_start, 3); } function test_StringManipulation($count = 1300000) { $time_start = get_microtime(); $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(get_microtime() - $time_start, 3); } function test_Loops($count = 190000000) { $time_start = get_microtime(); for($i = 0; $i < $count; ++$i); $i = 0; while($i++ < $count); return number_format(get_microtime() - $time_start, 3); } function test_IfElse($count = 90000000) { $time_start = get_microtime(); for ($i=0; $i < $count; $i++) { if ($i == -1) { } elseif ($i == -2) { } else if ($i == -3) { } } return number_format(get_microtime() - $time_start, 3); } $total = 0; $functions = get_defined_functions(); $line = str_pad("-",38,"-"); echo "<pre>\n$line\n|".str_pad("PHP BENCHMARK SCRIPT",36," ",STR_PAD_BOTH)."|\n$line\nStart : ".date("Y-m-d H:i:s")."\nServer : ".php_uname()."\nPHP version : ".PHP_VERSION."\nPlatform : ".PHP_OS. "\n$line\n"; foreach ($functions['user'] as $user) { if (preg_match('/^test_/', $user)) { $result = $user(); $total += $result; echo str_pad($user, 25) . " : " . $result ." sec.\n"; } } echo str_pad("-", 38, "-") . "\n" . str_pad("Total time:", 25) . " : " . $total ." sec.\n</pre>\n";
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 46, Position 2 = 65
Branch analysis from position: 46
2 jumps found. (Code = 78) Position 1 = 47, Position 2 = 65
Branch analysis from position: 47
2 jumps found. (Code = 43) Position 1 = 52, Position 2 = 64
Branch analysis from position: 52
1 jumps found. (Code = 42) Position 1 = 46
Branch analysis from position: 46
Branch analysis from position: 64
Branch analysis from position: 65
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 65
filename:       /in/CLZfm
function name:  (null)
number of ops:  82
compiled vars:  !0 = $total, !1 = $functions, !2 = $line, !3 = $user, !4 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   INIT_FCALL                                               'set_time_limit'
          1        SEND_VAL                                                 0
          2        DO_ICALL                                                 
   80     3        ASSIGN                                                   !0, 0
   81     4        INIT_FCALL                                               'get_defined_functions'
          5        DO_ICALL                                         $7      
          6        ASSIGN                                                   !1, $7
   82     7        INIT_FCALL                                               'str_pad'
          8        SEND_VAL                                                 '-'
          9        SEND_VAL                                                 38
         10        SEND_VAL                                                 '-'
         11        DO_ICALL                                         $9      
         12        ASSIGN                                                   !2, $9
   83    13        ROPE_INIT                                     3  ~12     '%3Cpre%3E%0A'
         14        ROPE_ADD                                      1  ~12     ~12, !2
         15        ROPE_END                                      2  ~11     ~12, '%0A%7C'
         16        INIT_FCALL                                               'str_pad'
         17        SEND_VAL                                                 'PHP+BENCHMARK+SCRIPT'
         18        SEND_VAL                                                 36
         19        SEND_VAL                                                 '+'
         20        SEND_VAL                                                 2
         21        DO_ICALL                                         $14     
         22        CONCAT                                           ~15     ~11, $14
         23        ROPE_INIT                                     3  ~17     '%7C%0A'
         24        ROPE_ADD                                      1  ~17     ~17, !2
         25        ROPE_END                                      2  ~16     ~17, '%0AStart+%3A+'
         26        CONCAT                                           ~19     ~15, ~16
         27        INIT_FCALL                                               'date'
         28        SEND_VAL                                                 'Y-m-d+H%3Ai%3As'
         29        DO_ICALL                                         $20     
         30        CONCAT                                           ~21     ~19, $20
         31        CONCAT                                           ~22     ~21, '%0AServer+%3A+'
         32        INIT_FCALL                                               'php_uname'
         33        DO_ICALL                                         $23     
         34        CONCAT                                           ~24     ~22, $23
         35        CONCAT                                           ~25     ~24, '%0APHP+version+%3A+'
         36        CONCAT                                           ~26     ~25, '8.0.0'
         37        CONCAT                                           ~27     ~26, '%0APlatform+%3A+'
         38        CONCAT                                           ~28     ~27, 'Linux'
         39        ROPE_INIT                                     3  ~30     '%0A'
         40        ROPE_ADD                                      1  ~30     ~30, !2
         41        ROPE_END                                      2  ~29     ~30, '%0A'
         42        CONCAT                                           ~32     ~28, ~29
         43        ECHO                                                     ~32
   84    44        FETCH_DIM_R                                      ~33     !1, 'user'
         45      > FE_RESET_R                                       $34     ~33, ->65
         46    > > FE_FETCH_R                                               $34, !3, ->65
   85    47    >   INIT_FCALL                                               'preg_match'
         48        SEND_VAL                                                 '%2F%5Etest_%2F'
         49        SEND_VAR                                                 !3
         50        DO_ICALL                                         $35     
         51      > JMPZ                                                     $35, ->64
   86    52    >   INIT_DYNAMIC_CALL                                        !3
         53        DO_FCALL                                      0  $36     
         54        ASSIGN                                                   !4, $36
   87    55        ASSIGN_OP                                     1          !0, !4
   88    56        INIT_FCALL                                               'str_pad'
         57        SEND_VAR                                                 !3
         58        SEND_VAL                                                 25
         59        DO_ICALL                                         $39     
         60        CONCAT                                           ~40     $39, '+%3A+'
         61        CONCAT                                           ~41     ~40, !4
         62        CONCAT                                           ~42     ~41, '+sec.%0A'
         63        ECHO                                                     ~42
   84    64    > > JMP                                                      ->46
         65    >   FE_FREE                                                  $34
   91    66        INIT_FCALL                                               'str_pad'
         67        SEND_VAL                                                 '-'
         68        SEND_VAL                                                 38
         69        SEND_VAL                                                 '-'
         70        DO_ICALL                                         $43     
         71        CONCAT                                           ~44     $43, '%0A'
         72        INIT_FCALL                                               'str_pad'
         73        SEND_VAL                                                 'Total+time%3A'
         74        SEND_VAL                                                 25
         75        DO_ICALL                                         $45     
         76        CONCAT                                           ~46     ~44, $45
         77        CONCAT                                           ~47     ~46, '+%3A+'
         78        CONCAT                                           ~48     ~47, !0
         79        CONCAT                                           ~49     ~48, '+sec.%0A%3C%2Fpre%3E%0A'
         80        ECHO                                                     ~49
         81      > RETURN                                                   1

Function get_microtime:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 19
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
filename:       /in/CLZfm
function name:  get_microtime
number of ops:  21
compiled vars:  !0 = $time, !1 = $f, !2 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   INIT_FCALL                                               'microtime'
          1        SEND_VAL                                                 <true>
          2        DO_ICALL                                         $3      
          3        ASSIGN                                                   !0, $3
   22     4        TYPE_CHECK                                   64          !0
          5      > JMPZ                                                     ~5, ->19
   23     6    >   INIT_FCALL                                               'explode'
          7        SEND_VAL                                                 '+'
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                         $6      
         10        FETCH_LIST_R                                     $7      $6, 0
         11        ASSIGN                                                   !1, $7
         12        FETCH_LIST_R                                     $9      $6, 1
         13        ASSIGN                                                   !2, $9
         14        FREE                                                     $6
   24    15        CAST                                          4  ~11     !2
         16        CAST                                          5  ~12     !1
         17        ADD                                              ~13     ~11, ~12
         18        ASSIGN                                                   !0, ~13
   26    19    > > RETURN                                                   !0
   27    20*     > RETURN                                                   null

End of function get_microtime

Function test_math:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 15
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 15
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 14
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 14
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 18
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
2 jumps found. (Code = 77) Position 1 = 19, Position 2 = 27
Branch analysis from position: 19
2 jumps found. (Code = 78) Position 1 = 20, Position 2 = 27
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
Branch analysis from position: 27
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 18
Branch analysis from position: 31
Branch analysis from position: 18
Branch analysis from position: 27
Branch analysis from position: 15
filename:       /in/CLZfm
function name:  test_Math
number of ops:  40
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
-------------------------------------------------------------------------------------
   29     0  E >   RECV_INIT                                        !0      1400000
   30     1        INIT_FCALL                                               'get_microtime'
          2        DO_FCALL                                      0  $7      
          3        ASSIGN                                                   !1, $7
   31     4        ASSIGN                                                   !2, <array>
   32     5      > FE_RESET_R                                       $10     !2, ->15
          6    > > FE_FETCH_R                                       ~11     $10, !3, ->15
          7    >   ASSIGN                                                   !4, ~11
   33     8        INIT_FCALL                                               'function_exists'
          9        SEND_VAR                                                 !3
         10        DO_ICALL                                         $13     
         11        BOOL_NOT                                         ~14     $13
         12      > JMPZ                                                     ~14, ->14
         13    >   UNSET_DIM                                                !2, !4
   32    14    > > JMP                                                      ->6
         15    >   FE_FREE                                                  $10
   35    16        ASSIGN                                                   !5, 0
         17      > JMP                                                      ->29
   36    18    > > FE_RESET_R                                       $16     !2, ->27
         19    > > FE_FETCH_R                                               $16, !3, ->27
   37    20    >   INIT_USER_CALL                                0          'call_user_func_array', !3
         21        INIT_ARRAY                                       ~17     !5
         22        SEND_ARRAY                                               ~17
         23        CHECK_UNDEF_ARGS                                         
         24        DO_FCALL                                      0  $18     
         25        ASSIGN                                                   !6, $18
   36    26      > JMP                                                      ->19
         27    >   FE_FREE                                                  $16
   35    28        PRE_INC                                                  !5
         29    >   IS_SMALLER                                               !5, !0
         30      > JMPNZ                                                    ~21, ->18
   40    31    >   INIT_FCALL                                               'number_format'
         32        INIT_FCALL                                               'get_microtime'
         33        DO_FCALL                                      0  $22     
         34        SUB                                              ~23     $22, !1
         35        SEND_VAL                                                 ~23
         36        SEND_VAL                                                 3
         37        DO_ICALL                                         $24     
         38      > RETURN                                                   $24
   41    39*     > 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 = 6, Position 2 = 15
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 15
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 14
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 14
Branch analysis from position: 15
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: 15
filename:       /in/CLZfm
function name:  test_StringManipulation
number of ops:  41
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
-------------------------------------------------------------------------------------
   44     0  E >   RECV_INIT                                        !0      1300000
   45     1        INIT_FCALL                                               'get_microtime'
          2        DO_FCALL                                      0  $8      
          3        ASSIGN                                                   !1, $8
   46     4        ASSIGN                                                   !2, <array>
   47     5      > FE_RESET_R                                       $11     !2, ->15
          6    > > FE_FETCH_R                                       ~12     $11, !3, ->15
          7    >   ASSIGN                                                   !4, ~12
   48     8        INIT_FCALL                                               'function_exists'
          9        SEND_VAR                                                 !3
         10        DO_ICALL                                         $14     
         11        BOOL_NOT                                         ~15     $14
         12      > JMPZ                                                     ~15, ->14
         13    >   UNSET_DIM                                                !2, !4
   47    14    > > JMP                                                      ->6
         15    >   FE_FREE                                                  $11
   50    16        ASSIGN                                                   !5, 'the+quick+brown+fox+jumps+over+the+lazy+dog'
   51    17        ASSIGN                                                   !6, 0
         18      > JMP                                                      ->30
   52    19    > > FE_RESET_R                                       $18     !2, ->28
         20    > > FE_FETCH_R                                               $18, !3, ->28
   53    21    >   INIT_USER_CALL                                0          'call_user_func_array', !3
         22        INIT_ARRAY                                       ~19     !5
         23        SEND_ARRAY                                               ~19
         24        CHECK_UNDEF_ARGS                                         
         25        DO_FCALL                                      0  $20     
         26        ASSIGN                                                   !7, $20
   52    27      > JMP                                                      ->20
         28    >   FE_FREE                                                  $18
   51    29        PRE_INC                                                  !6
         30    >   IS_SMALLER                                               !6, !0
         31      > JMPNZ                                                    ~23, ->19
   56    32    >   INIT_FCALL                                               'number_format'
         33        INIT_FCALL                                               'get_microtime'
         34        DO_FCALL                                      0  $24     
         35        SUB                                              ~25     $24, !1
         36        SEND_VAL                                                 ~25
         37        SEND_VAL                                                 3
         38        DO_ICALL                                         $26     
         39      > RETURN                                                   $26
   57    40*     > 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 = 7
Branch analysis from position: 7
2 jumps found. (Code = 44) Position 1 = 9, Position 2 = 6
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 11
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
Branch analysis from position: 6
2 jumps found. (Code = 44) Position 1 = 9, Position 2 = 6
Branch analysis from position: 9
Branch analysis from position: 6
filename:       /in/CLZfm
function name:  test_Loops
number of ops:  23
compiled vars:  !0 = $count, !1 = $time_start, !2 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   60     0  E >   RECV_INIT                                        !0      190000000
   61     1        INIT_FCALL                                               'get_microtime'
          2        DO_FCALL                                      0  $3      
          3        ASSIGN                                                   !1, $3
   62     4        ASSIGN                                                   !2, 0
          5      > JMP                                                      ->7
          6    >   PRE_INC                                                  !2
          7    >   IS_SMALLER                                               !2, !0
          8      > JMPNZ                                                    ~7, ->6
   63     9    >   ASSIGN                                                   !2, 0
         10      > JMP                                                      ->11
         11    >   POST_INC                                         ~9      !2
         12        IS_SMALLER                                               ~9, !0
         13      > JMPNZ                                                    ~10, ->11
   64    14    >   INIT_FCALL                                               'number_format'
         15        INIT_FCALL                                               'get_microtime'
         16        DO_FCALL                                      0  $11     
         17        SUB                                              ~12     $11, !1
         18        SEND_VAL                                                 ~12
         19        SEND_VAL                                                 3
         20        DO_ICALL                                         $13     
         21      > RETURN                                                   $13
   65    22*     > 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 = 15
Branch analysis from position: 15
2 jumps found. (Code = 44) Position 1 = 17, Position 2 = 6
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 9
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
2 jumps found. (Code = 44) Position 1 = 17, Position 2 = 6
Branch analysis from position: 17
Branch analysis from position: 6
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 12
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 14
Branch analysis from position: 14
Branch analysis from position: 14
filename:       /in/CLZfm
function name:  test_IfElse
number of ops:  26
compiled vars:  !0 = $count, !1 = $time_start, !2 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   68     0  E >   RECV_INIT                                        !0      90000000
   69     1        INIT_FCALL                                               'get_microtime'
          2        DO_FCALL                                      0  $3      
          3        ASSIGN                                                   !1, $3
   70     4        ASSIGN                                                   !2, 0
          5      > JMP                                                      ->15
   71     6    >   IS_EQUAL                                                 !2, -1
          7      > JMPZ                                                     ~6, ->9
          8    > > JMP                                                      ->14
   72     9    >   IS_EQUAL                                                 !2, -2
         10      > JMPZ                                                     ~7, ->12
         11    > > JMP                                                      ->14
   73    12    >   IS_EQUAL                                                 !2, -3
         13      > JMPZ                                                     ~8, ->14
   70    14    >   PRE_INC                                                  !2
         15    >   IS_SMALLER                                               !2, !0
         16      > JMPNZ                                                    ~10, ->6
   76    17    >   INIT_FCALL                                               'number_format'
         18        INIT_FCALL                                               'get_microtime'
         19        DO_FCALL                                      0  $11     
         20        SUB                                              ~12     $11, !1
         21        SEND_VAL                                                 ~12
         22        SEND_VAL                                                 3
         23        DO_ICALL                                         $13     
         24      > RETURN                                                   $13
   77    25*     > RETURN                                                   null

End of function test_ifelse

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
173.69 ms | 1423 KiB | 41 Q