服务器基准测试php性能
我在不同的公司有几个托管帐户,我正在尝试评估哪一个会以最快的速度安装Wordpress(而不必先在每个公司上安装Wordpress) 我找到了一个php基准测试脚本,试图确定哪一个工作得最好,结果很奇怪服务器基准测试php性能,php,wordpress,benchmarking,Php,Wordpress,Benchmarking,我在不同的公司有几个托管帐户,我正在尝试评估哪一个会以最快的速度安装Wordpress(而不必先在每个公司上安装Wordpress) 我找到了一个php基准测试脚本,试图确定哪一个工作得最好,结果很奇怪 <?php /* ########################################################################## # PHP Benchmark Performance Script
<?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", "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>";
?>
您需要实际安装wordpress才能确定
我只需要编辑每个和的index.php文件
您需要实际安装wordpress才能确定
我只需要编辑每个和的index.php文件
您必须安装wordpress才能分析每个版本的性能。事实上,您应该在这三个版本中安装完整的wordpress环境,我的意思是,所有wordpress插件都应该安装,因为它们可能会对性能产生很大影响。此外,apache、mysql和php应该在所有三台服务器中进行相同的调优
一旦这样做,就可以使用jMeter(http://jmeter.apache.org/)要真正测试您的服务器,并查看您的服务器可以提供多少请求。您必须安装wordpress才能分析每个请求的性能。事实上,您应该在这三个版本中安装完整的wordpress环境,我的意思是,所有wordpress插件都应该安装,因为它们可能会对性能产生很大影响。此外,apache、mysql和php应该在所有三台服务器中进行相同的调优
一旦这样做,就可以使用jMeter(http://jmeter.apache.org/)要真正测试您的服务器,并查看您的服务器可以服务多少请求
<?php
/**
* Front to the WordPress application. This file doesn't do anything, but loads
* wp-blog-header.php which does and tells WordPress to load the theme.
*
* @package WordPress
*/
require('benchmark.php');
/**
* Tells WordPress to load the WordPress theme and output it.
*
* @var bool
*/
define('WP_USE_THEMES', true);
/** Loads the WordPress Environment and Template */
require('./wp-blog-header.php');