3v4l.org

run code in 300+ PHP versions simultaneously
<?php $_SERVER['SERVER_NAME'] = 'test'; $_SERVER['SERVER_ADDR'] = 'localhost'; /* ########################################################################## # 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", "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 = 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 : {$_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 = 54, Position 2 = 73
Branch analysis from position: 54
2 jumps found. (Code = 78) Position 1 = 55, Position 2 = 73
Branch analysis from position: 55
2 jumps found. (Code = 43) Position 1 = 60, Position 2 = 72
Branch analysis from position: 60
1 jumps found. (Code = 42) Position 1 = 54
Branch analysis from position: 54
Branch analysis from position: 72
Branch analysis from position: 73
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 73
filename:       /in/QAvvK
function name:  (null)
number of ops:  90
compiled vars:  !0 = $total, !1 = $functions, !2 = $line, !3 = $user, !4 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   FETCH_W                      global              $5      '_SERVER'
          1        ASSIGN_DIM                                               $5, 'SERVER_NAME'
          2        OP_DATA                                                  'test'
    3     3        FETCH_W                      global              $7      '_SERVER'
          4        ASSIGN_DIM                                               $7, 'SERVER_ADDR'
          5        OP_DATA                                                  'localhost'
   71     6        ASSIGN                                                   !0, 0
   72     7        INIT_FCALL                                               'get_defined_functions'
          8        DO_ICALL                                         $10     
          9        ASSIGN                                                   !1, $10
   73    10        INIT_FCALL                                               'str_pad'
         11        SEND_VAL                                                 '-'
         12        SEND_VAL                                                 38
         13        SEND_VAL                                                 '-'
         14        DO_ICALL                                         $12     
         15        ASSIGN                                                   !2, $12
   74    16        ROPE_INIT                                     3  ~15     '%3Cpre%3E'
         17        ROPE_ADD                                      1  ~15     ~15, !2
         18        ROPE_END                                      2  ~14     ~15, '%0A%7C'
         19        INIT_FCALL                                               'str_pad'
         20        SEND_VAL                                                 'PHP+BENCHMARK+SCRIPT'
         21        SEND_VAL                                                 36
         22        SEND_VAL                                                 '+'
         23        SEND_VAL                                                 2
         24        DO_ICALL                                         $17     
         25        CONCAT                                           ~18     ~14, $17
         26        ROPE_INIT                                     3  ~20     '%7C%0A'
         27        ROPE_ADD                                      1  ~20     ~20, !2
         28        ROPE_END                                      2  ~19     ~20, '%0AStart+%3A+'
         29        CONCAT                                           ~22     ~18, ~19
         30        INIT_FCALL                                               'date'
         31        SEND_VAL                                                 'Y-m-d+H%3Ai%3As'
         32        DO_ICALL                                         $23     
         33        CONCAT                                           ~24     ~22, $23
         34        ROPE_INIT                                     5  ~30     '%0AServer+%3A+'
         35        FETCH_R                      global              ~25     '_SERVER'
         36        FETCH_DIM_R                                      ~26     ~25, 'SERVER_NAME'
         37        ROPE_ADD                                      1  ~30     ~30, ~26
         38        ROPE_ADD                                      2  ~30     ~30, '%40'
         39        FETCH_R                      global              ~27     '_SERVER'
         40        FETCH_DIM_R                                      ~28     ~27, 'SERVER_ADDR'
         41        ROPE_ADD                                      3  ~30     ~30, ~28
         42        ROPE_END                                      4  ~29     ~30, '%0APHP+version+%3A+'
         43        CONCAT                                           ~33     ~24, ~29
         44        CONCAT                                           ~34     ~33, '8.0.0'
         45        CONCAT                                           ~35     ~34, '%0APlatform+%3A+'
         46        CONCAT                                           ~36     ~35, 'Linux'
         47        ROPE_INIT                                     3  ~38     '%0A'
         48        ROPE_ADD                                      1  ~38     ~38, !2
         49        ROPE_END                                      2  ~37     ~38, '%0A'
         50        CONCAT                                           ~40     ~36, ~37
         51        ECHO                                                     ~40
   75    52        FETCH_DIM_R                                      ~41     !1, 'user'
         53      > FE_RESET_R                                       $42     ~41, ->73
         54    > > FE_FETCH_R                                               $42, !3, ->73
   76    55    >   INIT_FCALL                                               'preg_match'
         56        SEND_VAL                                                 '%2F%5Etest_%2F'
         57        SEND_VAR                                                 !3
         58        DO_ICALL                                         $43     
         59      > JMPZ                                                     $43, ->72
   77    60    >   INIT_DYNAMIC_CALL                                        !3
         61        DO_FCALL                                      0  $44     
         62        ASSIGN                                           ~45     !4, $44
         63        ASSIGN_OP                                     1          !0, ~45
   78    64        INIT_FCALL                                               'str_pad'
         65        SEND_VAR                                                 !3
         66        SEND_VAL                                                 25
         67        DO_ICALL                                         $47     
         68        CONCAT                                           ~48     $47, '+%3A+'
         69        CONCAT                                           ~49     ~48, !4
         70        CONCAT                                           ~50     ~49, '+sec.%0A'
         71        ECHO                                                     ~50
   75    72    > > JMP                                                      ->54
         73    >   FE_FREE                                                  $42
   81    74        INIT_FCALL                                               'str_pad'
         75        SEND_VAL                                                 '-'
         76        SEND_VAL                                                 38
         77        SEND_VAL                                                 '-'
         78        DO_ICALL                                         $51     
         79        CONCAT                                           ~52     $51, '%0A'
         80        INIT_FCALL                                               'str_pad'
         81        SEND_VAL                                                 'Total+time%3A'
         82        SEND_VAL                                                 25
         83        DO_ICALL                                         $53     
         84        CONCAT                                           ~54     ~52, $53
         85        CONCAT                                           ~55     ~54, '+%3A+'
         86        CONCAT                                           ~56     ~55, !0
         87        CONCAT                                           ~57     ~56, '+sec.%3C%2Fpre%3E'
         88        ECHO                                                     ~57
   83    89      > 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/QAvvK
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
-------------------------------------------------------------------------------------
   20     0  E >   RECV_INIT                                        !0      140000
   21     1        INIT_FCALL                                               'microtime'
          2        SEND_VAL                                                 <true>
          3        DO_ICALL                                         $7      
          4        ASSIGN                                                   !1, $7
   22     5        ASSIGN                                                   !2, <array>
   23     6      > FE_RESET_R                                       $10     !2, ->16
          7    > > FE_FETCH_R                                       ~11     $10, !3, ->16
          8    >   ASSIGN                                                   !4, ~11
   24     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
   23    15    > > JMP                                                      ->7
         16    >   FE_FREE                                                  $10
   26    17        ASSIGN                                                   !5, 0
         18      > JMP                                                      ->30
   27    19    > > FE_RESET_R                                       $16     !2, ->28
         20    > > FE_FETCH_R                                               $16, !3, ->28
   28    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
   27    27      > JMP                                                      ->20
         28    >   FE_FREE                                                  $16
   26    29        PRE_INC                                                  !5
         30    >   IS_SMALLER                                               !5, !0
         31      > JMPNZ                                                    ~21, ->19
   31    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
   32    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/QAvvK
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
-------------------------------------------------------------------------------------
   35     0  E >   RECV_INIT                                        !0      130000
   36     1        INIT_FCALL                                               'microtime'
          2        SEND_VAL                                                 <true>
          3        DO_ICALL                                         $8      
          4        ASSIGN                                                   !1, $8
   37     5        ASSIGN                                                   !2, <array>
   38     6      > FE_RESET_R                                       $11     !2, ->16
          7    > > FE_FETCH_R                                       ~12     $11, !3, ->16
          8    >   ASSIGN                                                   !4, ~12
   39     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
   38    15    > > JMP                                                      ->7
         16    >   FE_FREE                                                  $11
   41    17        ASSIGN                                                   !5, 'the+quick+brown+fox+jumps+over+the+lazy+dog'
   42    18        ASSIGN                                                   !6, 0
         19      > JMP                                                      ->31
   43    20    > > FE_RESET_R                                       $18     !2, ->29
         21    > > FE_FETCH_R                                               $18, !3, ->29
   44    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
   43    28      > JMP                                                      ->21
         29    >   FE_FREE                                                  $18
   42    30        PRE_INC                                                  !6
         31    >   IS_SMALLER                                               !6, !0
         32      > JMPNZ                                                    ~23, ->20
   47    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
   48    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/QAvvK
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
-------------------------------------------------------------------------------------
   51     0  E >   RECV_INIT                                        !0      19000000
   52     1        INIT_FCALL                                               'microtime'
          2        SEND_VAL                                                 <true>
          3        DO_ICALL                                         $3      
          4        ASSIGN                                                   !1, $3
   53     5        ASSIGN                                                   !2, 0
          6      > JMP                                                      ->8
          7    >   PRE_INC                                                  !2
          8    >   IS_SMALLER                                               !2, !0
          9      > JMPNZ                                                    ~7, ->7
   54    10    >   ASSIGN                                                   !2, 0
         11      > JMP                                                      ->13
         12    >   PRE_INC                                                  !2
         13    >   IS_SMALLER                                               !2, !0
         14      > JMPNZ                                                    ~10, ->12
   55    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
   56    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/QAvvK
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
-------------------------------------------------------------------------------------
   59     0  E >   RECV_INIT                                        !0      9000000
   60     1        INIT_FCALL                                               'microtime'
          2        SEND_VAL                                                 <true>
          3        DO_ICALL                                         $3      
          4        ASSIGN                                                   !1, $3
   61     5        ASSIGN                                                   !2, 0
          6      > JMP                                                      ->16
   62     7    >   IS_EQUAL                                                 !2, -1
          8      > JMPZ                                                     ~6, ->10
          9    > > JMP                                                      ->15
   63    10    >   IS_EQUAL                                                 !2, -2
         11      > JMPZ                                                     ~7, ->13
         12    > > JMP                                                      ->15
   64    13    >   IS_EQUAL                                                 !2, -3
         14      > JMPZ                                                     ~8, ->15
   61    15    >   PRE_INC                                                  !2
         16    >   IS_SMALLER                                               !2, !0
         17      > JMPNZ                                                    ~10, ->7
   67    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
   68    27*     > RETURN                                                   null

End of function test_ifelse

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.97 ms | 1420 KiB | 27 Q