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 = 140000) { $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 = 130000) { $time_start = microtime(true); $stringFunctions = array("addslashes", "chunk_split", "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"; foreach ($stringFunctions as $function) { $time_start_sub = microtime(true); for ($i=0; $i < $count; $i++) { $r = call_user_func_array($function, array($string)); } echo str_pad($function, 15) . ": " . number_format(microtime(true) - $time_start_sub, 3) . "\n"; } return number_format(microtime(true) - $time_start, 3); } function test_Loops($count = 19000000) { $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 = 9000000) { $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 : \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 = 39, Position 2 = 58
Branch analysis from position: 39
2 jumps found. (Code = 78) Position 1 = 40, Position 2 = 58
Branch analysis from position: 40
2 jumps found. (Code = 43) Position 1 = 45, Position 2 = 57
Branch analysis from position: 45
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
Branch analysis from position: 57
Branch analysis from position: 58
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 58
filename:       /in/Kq6oJ
function name:  (null)
number of ops:  75
compiled vars:  !0 = $total, !1 = $functions, !2 = $line, !3 = $user, !4 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   70     0  E >   ASSIGN                                                   !0, 0
   71     1        INIT_FCALL                                               'get_defined_functions'
          2        DO_ICALL                                         $6      
          3        ASSIGN                                                   !1, $6
   72     4        INIT_FCALL                                               'str_pad'
          5        SEND_VAL                                                 '-'
          6        SEND_VAL                                                 38
          7        SEND_VAL                                                 '-'
          8        DO_ICALL                                         $8      
          9        ASSIGN                                                   !2, $8
   73    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        CONCAT                                           ~21     ~20, '%0AServer+%3A+%0APHP+version+%3A+'
         29        CONCAT                                           ~22     ~21, '8.0.0'
         30        CONCAT                                           ~23     ~22, '%0APlatform+%3A+'
         31        CONCAT                                           ~24     ~23, 'Linux'
         32        ROPE_INIT                                     3  ~26     '%0A'
         33        ROPE_ADD                                      1  ~26     ~26, !2
         34        ROPE_END                                      2  ~25     ~26, '%0A'
         35        CONCAT                                           ~28     ~24, ~25
         36        ECHO                                                     ~28
   74    37        FETCH_DIM_R                                      ~29     !1, 'user'
         38      > FE_RESET_R                                       $30     ~29, ->58
         39    > > FE_FETCH_R                                               $30, !3, ->58
   75    40    >   INIT_FCALL                                               'preg_match'
         41        SEND_VAL                                                 '%2F%5Etest_%2F'
         42        SEND_VAR                                                 !3
         43        DO_ICALL                                         $31     
         44      > JMPZ                                                     $31, ->57
   76    45    >   INIT_DYNAMIC_CALL                                        !3
         46        DO_FCALL                                      0  $32     
         47        ASSIGN                                           ~33     !4, $32
         48        ASSIGN_OP                                     1          !0, ~33
   77    49        INIT_FCALL                                               'str_pad'
         50        SEND_VAR                                                 !3
         51        SEND_VAL                                                 25
         52        DO_ICALL                                         $35     
         53        CONCAT                                           ~36     $35, '+%3A+'
         54        CONCAT                                           ~37     ~36, !4
         55        CONCAT                                           ~38     ~37, '+sec.%0A'
         56        ECHO                                                     ~38
   74    57    > > JMP                                                      ->39
         58    >   FE_FREE                                                  $30
   80    59        INIT_FCALL                                               'str_pad'
         60        SEND_VAL                                                 '-'
         61        SEND_VAL                                                 38
         62        SEND_VAL                                                 '-'
         63        DO_ICALL                                         $39     
         64        CONCAT                                           ~40     $39, '%0A'
         65        INIT_FCALL                                               'str_pad'
         66        SEND_VAL                                                 'Total+time%3A'
         67        SEND_VAL                                                 25
         68        DO_ICALL                                         $41     
         69        CONCAT                                           ~42     ~40, $41
         70        CONCAT                                           ~43     ~42, '+%3A+'
         71        CONCAT                                           ~44     ~43, !0
         72        CONCAT                                           ~45     ~44, '+sec.%3C%2Fpre%3E'
         73        ECHO                                                     ~45
   82    74      > 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/Kq6oJ
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      140000
   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
2 jumps found. (Code = 77) Position 1 = 19, Position 2 = 52
Branch analysis from position: 19
2 jumps found. (Code = 78) Position 1 = 20, Position 2 = 52
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
2 jumps found. (Code = 44) Position 1 = 35, Position 2 = 26
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
Branch analysis from position: 26
2 jumps found. (Code = 44) Position 1 = 35, Position 2 = 26
Branch analysis from position: 35
Branch analysis from position: 26
Branch analysis from position: 52
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 52
Branch analysis from position: 16
filename:       /in/Kq6oJ
function name:  test_StringManipulation
number of ops:  63
compiled vars:  !0 = $count, !1 = $time_start, !2 = $stringFunctions, !3 = $function, !4 = $key, !5 = $string, !6 = $time_start_sub, !7 = $i, !8 = $r
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   RECV_INIT                                        !0      130000
   33     1        INIT_FCALL                                               'microtime'
          2        SEND_VAL                                                 <true>
          3        DO_ICALL                                         $9      
          4        ASSIGN                                                   !1, $9
   34     5        ASSIGN                                                   !2, <array>
   35     6      > FE_RESET_R                                       $12     !2, ->16
          7    > > FE_FETCH_R                                       ~13     $12, !3, ->16
          8    >   ASSIGN                                                   !4, ~13
   36     9        INIT_FCALL                                               'function_exists'
         10        SEND_VAR                                                 !3
         11        DO_ICALL                                         $15     
         12        BOOL_NOT                                         ~16     $15
         13      > JMPZ                                                     ~16, ->15
         14    >   UNSET_DIM                                                !2, !4
   35    15    > > JMP                                                      ->7
         16    >   FE_FREE                                                  $12
   38    17        ASSIGN                                                   !5, 'the+quick+brown+fox+jumps+over+the+lazy+dog'
   39    18      > FE_RESET_R                                       $18     !2, ->52
         19    > > FE_FETCH_R                                               $18, !3, ->52
   40    20    >   INIT_FCALL                                               'microtime'
         21        SEND_VAL                                                 <true>
         22        DO_ICALL                                         $19     
         23        ASSIGN                                                   !6, $19
   41    24        ASSIGN                                                   !7, 0
         25      > JMP                                                      ->33
   42    26    >   INIT_USER_CALL                                0          'call_user_func_array', !3
         27        INIT_ARRAY                                       ~22     !5
         28        SEND_ARRAY                                               ~22
         29        CHECK_UNDEF_ARGS                                         
         30        DO_FCALL                                      0  $23     
         31        ASSIGN                                                   !8, $23
   41    32        PRE_INC                                                  !7
         33    >   IS_SMALLER                                               !7, !0
         34      > JMPNZ                                                    ~26, ->26
   44    35    >   INIT_FCALL                                               'str_pad'
         36        SEND_VAR                                                 !3
         37        SEND_VAL                                                 15
         38        DO_ICALL                                         $27     
         39        CONCAT                                           ~28     $27, '%3A+'
         40        INIT_FCALL                                               'number_format'
         41        INIT_FCALL                                               'microtime'
         42        SEND_VAL                                                 <true>
         43        DO_ICALL                                         $29     
         44        SUB                                              ~30     $29, !6
         45        SEND_VAL                                                 ~30
         46        SEND_VAL                                                 3
         47        DO_ICALL                                         $31     
         48        CONCAT                                           ~32     ~28, $31
         49        CONCAT                                           ~33     ~32, '%0A'
         50        ECHO                                                     ~33
   39    51      > JMP                                                      ->19
         52    >   FE_FREE                                                  $18
   46    53        INIT_FCALL                                               'number_format'
         54        INIT_FCALL                                               'microtime'
         55        SEND_VAL                                                 <true>
         56        DO_ICALL                                         $34     
         57        SUB                                              ~35     $34, !1
         58        SEND_VAL                                                 ~35
         59        SEND_VAL                                                 3
         60        DO_ICALL                                         $36     
         61      > RETURN                                                   $36
   47    62*     > 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/Kq6oJ
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
-------------------------------------------------------------------------------------
   50     0  E >   RECV_INIT                                        !0      19000000
   51     1        INIT_FCALL                                               'microtime'
          2        SEND_VAL                                                 <true>
          3        DO_ICALL                                         $3      
          4        ASSIGN                                                   !1, $3
   52     5        ASSIGN                                                   !2, 0
          6      > JMP                                                      ->8
          7    >   PRE_INC                                                  !2
          8    >   IS_SMALLER                                               !2, !0
          9      > JMPNZ                                                    ~7, ->7
   53    10    >   ASSIGN                                                   !2, 0
         11      > JMP                                                      ->13
         12    >   PRE_INC                                                  !2
         13    >   IS_SMALLER                                               !2, !0
         14      > JMPNZ                                                    ~10, ->12
   54    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
   55    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/Kq6oJ
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
-------------------------------------------------------------------------------------
   58     0  E >   RECV_INIT                                        !0      9000000
   59     1        INIT_FCALL                                               'microtime'
          2        SEND_VAL                                                 <true>
          3        DO_ICALL                                         $3      
          4        ASSIGN                                                   !1, $3
   60     5        ASSIGN                                                   !2, 0
          6      > JMP                                                      ->16
   61     7    >   IS_EQUAL                                                 !2, -1
          8      > JMPZ                                                     ~6, ->10
          9    > > JMP                                                      ->15
   62    10    >   IS_EQUAL                                                 !2, -2
         11      > JMPZ                                                     ~7, ->13
         12    > > JMP                                                      ->15
   63    13    >   IS_EQUAL                                                 !2, -3
         14      > JMPZ                                                     ~8, ->15
   60    15    >   PRE_INC                                                  !2
         16    >   IS_SMALLER                                               !2, !0
         17      > JMPNZ                                                    ~10, ->7
   66    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
   67    27*     > RETURN                                                   null

End of function test_ifelse

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
176.95 ms | 1412 KiB | 27 Q