提高runtime的计算精度 避免吞吐率出现Division by zero错误

This commit is contained in:
thinkphp
2016-03-22 10:50:12 +08:00
parent 086fa8e9dd
commit abeafb4ab7
4 changed files with 8 additions and 4 deletions

View File

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

View File

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

View File

@@ -59,8 +59,9 @@ class Socket
if (!$this->check()) {
return false;
}
$runtime = number_format(microtime(true) - START_TIME, 6);
$runtime = microtime(true) - START_TIME;
$reqs = number_format(1 / $runtime, 2);
$runtime = number_format($runtime, 6);
$time_str = " [运行时间:{$runtime}s][吞吐率:{$reqs}req/s]";
$memory_use = number_format((memory_get_usage() - START_MEM) / 1024, 2);
$memory_str = " [内存消耗:{$memory_use}kb]";

View File

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