改进吞吐率计算

This commit is contained in:
thinkphp
2016-04-03 20:01:17 +08:00
parent ba7e7387ba
commit 45e593ec08
6 changed files with 6 additions and 6 deletions

View File

@@ -13,7 +13,7 @@ namespace think;
class Build
{
// 根据传入的build资料创建目录和文件
public static function run($build = [])
public static function run(array $build = [])
{
// 锁定
$lockfile = APP_PATH . 'build.lock';

View File

@@ -103,7 +103,7 @@ class Mysql extends Driver
list($field, $name) = explode($key, '$.');
$key = 'jsn_extract(' . $field . ', \'$.\'.' . $name . ')';
}
if (!preg_match('/[,\'\"\*\(\)`.\s]/', $key)) {
if ($key && !preg_match('/[,\'\"\*\(\)`.\s]/', $key)) {
$key = '`' . $key . '`';
}
return $key;

View File

@@ -54,7 +54,7 @@ class File
$current_uri = "cmd:" . implode(' ', $_SERVER['argv']);
}
$runtime = microtime(true) - START_TIME;
$reqs = number_format(1 / $runtime, 2);
$reqs = number_format(1 / number_format($runtime, 8), 2);
$runtime = number_format($runtime, 6);
$time_str = " [运行时间:{$runtime}s] [吞吐率:{$reqs}req/s]";
$memory_use = number_format((memory_get_usage() - START_MEM) / 1024, 2);

View File

@@ -42,7 +42,7 @@ class Sae
$current_uri = "cmd:" . implode(' ', $_SERVER['argv']);
}
$runtime = microtime(true) - START_TIME;
$reqs = number_format(1 / $runtime, 2);
$reqs = number_format(1 / number_format($runtime, 8), 2);
$runtime = number_format($runtime, 6);
$time_str = " [运行时间:{$runtime}s] [吞吐率:{$reqs}req/s]";
$memory_use = number_format((memory_get_usage() - START_MEM) / 1024, 2);

View File

@@ -60,7 +60,7 @@ class Socket
return false;
}
$runtime = microtime(true) - START_TIME;
$reqs = number_format(1 / $runtime, 2);
$reqs = number_format(1 / number_format($runtime, 8), 2);
$runtime = number_format($runtime, 6);
$time_str = " [运行时间:{$runtime}s][吞吐率:{$reqs}req/s]";
$memory_use = number_format((memory_get_usage() - START_MEM) / 1024, 2);

View File

@@ -44,7 +44,7 @@ class Trace
}
// 获取基本信息
$runtime = microtime(true) - START_TIME;
$reqs = number_format(1 / $runtime, 2);
$reqs = number_format(1 / number_format($runtime, 8), 2);
$runtime = number_format($runtime, 6);
$mem = number_format((memory_get_usage() - START_MEM) / 1024, 2);