取消microtime_float函数 取消MODE_PATH IS_API常量

This commit is contained in:
thinkphp
2016-06-29 20:39:38 +08:00
parent 207a77420e
commit 1a91aaa882
7 changed files with 26 additions and 38 deletions

View File

@@ -15,7 +15,6 @@ use think\Cache;
use think\Config;
use think\Db;
use think\Debug;
use think\Request;
/**
* 浏览器调试输出
@@ -43,7 +42,7 @@ class Console
public function output(array $log = [])
{
// 获取基本信息
$runtime = microtime_float() - START_TIME;
$runtime = number_format(microtime(true), 8, '.', '') - START_TIME;
$reqs = number_format(1 / $runtime, 2);
$mem = number_format((memory_get_usage() - START_MEM) / 1024, 2);
@@ -106,38 +105,38 @@ JS;
{
$type = strtolower($type);
$trace_tabs = array_values($this->config['trace_tabs']);
$line[] = ($type == $trace_tabs[0] || '调试' == $type || '错误'== $type)
? "console.group('{$type}');"
: "console.groupCollapsed('{$type}');";
$line[] = ($type == $trace_tabs[0] || '调试' == $type || '错误' == $type)
? "console.group('{$type}');"
: "console.groupCollapsed('{$type}');";
foreach ((array)$msg as $key => $m) {
foreach ((array) $msg as $key => $m) {
switch ($type) {
case '调试':
$var_type = gettype($m);
if(in_array($var_type, ['array', 'string'])){
$line[] = "console.log(".json_encode($m).");";
}else{
$line[] = "console.log(".json_encode(var_export($m, 1)).");";
if (in_array($var_type, ['array', 'string'])) {
$line[] = "console.log(" . json_encode($m) . ");";
} else {
$line[] = "console.log(" . json_encode(var_export($m, 1)) . ");";
}
break;
case '错误':
$msg = str_replace(PHP_EOL, '\n', $m);
$style = 'color:#F4006B;font-size:14px;';
$line[] = "console.error(\"%c{$msg}\", \"{$style}\");";
$msg = str_replace(PHP_EOL, '\n', $m);
$style = 'color:#F4006B;font-size:14px;';
$line[] = "console.error(\"%c{$msg}\", \"{$style}\");";
break;
case 'sql':
$msg = str_replace(PHP_EOL, '\n', $m);
$style = "color:#009bb4;";
$line[] = "console.log(\"%c{$msg}\", \"{$style}\");";
$msg = str_replace(PHP_EOL, '\n', $m);
$style = "color:#009bb4;";
$line[] = "console.log(\"%c{$msg}\", \"{$style}\");";
break;
default:
$m = is_string($key)? $key . ' ' . $m : $key+1 . ' ' . $m;
$msg = json_encode($m);
$line[] = "console.log({$msg});";
$m = is_string($key) ? $key . ' ' . $m : $key + 1 . ' ' . $m;
$msg = json_encode($m);
$line[] = "console.log({$msg});";
break;
}
}
$line[]= "console.groupEnd();";
$line[] = "console.groupEnd();";
return implode(PHP_EOL, $line);
}

View File

@@ -15,7 +15,6 @@ use think\Cache;
use think\Config;
use think\Db;
use think\Debug;
use think\Request;
/**
* 页面Trace调试
@@ -44,7 +43,7 @@ class Html
{
// 获取基本信息
$runtime = microtime_float() - START_TIME;
$runtime = number_format(microtime(true), 8, '.', '') - START_TIME;
$reqs = number_format(1 / $runtime, 2);
$mem = number_format((memory_get_usage() - START_MEM) / 1024, 2);

View File

@@ -54,7 +54,7 @@ class File
} else {
$current_uri = "cmd:" . implode(' ', $_SERVER['argv']);
}
$runtime = microtime_float() - START_TIME;
$runtime = number_format(microtime(true), 8, '.', '') - START_TIME;
$reqs = number_format(1 / $runtime, 2);
$time_str = " [运行时间:{$runtime}s] [吞吐率:{$reqs}req/s]";
$memory_use = number_format((memory_get_usage() - START_MEM) / 1024, 2);
@@ -66,7 +66,7 @@ class File
foreach ($val as $msg) {
if (!is_string($msg)) {
$msg = var_export($msg, true);
}
}
$info .= '[ ' . $type . ' ] ' . $msg . "\r\n";
}
}

View File

@@ -33,7 +33,7 @@ class Sae
} else {
$current_uri = "cmd:" . implode(' ', $_SERVER['argv']);
}
$runtime = microtime_float() - START_TIME;
$runtime = number_format(microtime(true), 8, '.', '') - START_TIME;
$reqs = number_format(1 / $runtime, 2);
$time_str = " [运行时间:{$runtime}s] [吞吐率:{$reqs}req/s]";
$memory_use = number_format((memory_get_usage() - START_MEM) / 1024, 2);
@@ -45,7 +45,7 @@ class Sae
foreach ($val as $msg) {
if (!is_string($msg)) {
$msg = var_export($msg, true);
}
}
$info .= '[ ' . $type . ' ] ' . $msg . "\r\n";
}
}

View File

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