Esempio n. 1
0
function debug_time($memory_ctrl = 1, $sql_ctrl = 1, $file_ctrl = 0, $cache_ctrl = 0)
{
    $time = run_time(true);
    $memory = run_memory(true);
    $sql_db_count = $GLOBALS['app']->db->conn_count();
    $sql_db_time = $GLOBALS['app']->db->conn_times();
    $sql_cache_count = $GLOBALS['app']->db->cache_count();
    $sql_cache_time = $GLOBALS['app']->db->cache_time();
    $string = P_Lang('运行{seconds_total}秒', array('seconds_total' => $time));
    //$string  = "运行 ".$time." 秒";
    if ($memory_ctrl && $memory_ctrl != 'false') {
        $string .= P_Lang(',内存使用{memory_total}', array('memory_total' => $memory));
    }
    if ($sql_ctrl && $sql_ctrl != 'false') {
        $string .= P_Lang(',数据库执行{sql_count}次,耗时{sql_time}秒', array('sql_count' => $sql_db_count, 'sql_time' => $sql_db_time));
        //$string .= ",数据库执行 ".$sql_db_count." 次,耗时 ".$sql_db_time." 秒";
    }
    if ($file_ctrl && $count > 0 && $file_ctrl != 'false') {
        $string .= P_Lang(',文件执行{file_count}次', array('file_count' => $count));
    }
    if ($cache_ctrl && $cache_ctrl != 'false') {
        $string .= P_Lang(',缓存执行{cache_count}次,耗时{cache_time}秒', array('cache_count' => $sql_cache_count, 'cache_time' => $sql_cache_time));
    }
    return $string;
}
Esempio n. 2
0
 /**
  * 显示错误信息
  * @access public
  * @param 参数类型  参数  参数说明
  * @return 返回值类型 返回值说明
  * 2015-5-8下午7:17:25
  */
 public static function show()
 {
     self::$debug[] = run_time("start", "end");
     echo "<div style='border:solid 2px #dcdcdc'>";
     foreach (self::$debug as $v) {
         echo $v . "<br>";
     }
     echo "</div>";
 }
Esempio n. 3
0
<?php

/*
		计算脚本运行时间函数
*/
function run_time($start, $end = '', $decimial = 3)
{
    static $times = array();
    if ($end != '') {
        $times[$end] = microtime();
        return number_format($times[$end] - $times[$start], $decimial);
    }
    $times[$start] = microtime();
}
//记录开始运行时间
run_time("start");
//项目初始化
defined('APP_PATH') or define('APP_PATH', dirname($_SERVER['SCRIPT_FILENAME']));
//定义应用
define('APPLICATION_DIR', 'blog');
//定义网站主目录
defined('ROOT') or define('ROOT', dirname($_SERVER['SCRIPT_NAME']));
//框架主目录
define("PHP_PATH", dirname(__FILE__));
//定义框架的资源目录
define('STATICS', APP_PATH . '/' . 'statics');
define('TEMP_PATH', APP_PATH . '/' . 'temp');
// URL 模式定义
const URL_COMMON = 0;
//普通模式
const URL_PATHINFO = 1;
Esempio n. 4
0
<?php

if (!defined('IN_TG')) {
    exit('非法访问!');
}
?>
<div id="footer">
    <p>运行时间<?php 
echo round(run_time() - START_TIME, 4);
?>
</p>
           <p>版权所有 翻版必究</p>
</div>

Esempio n. 5
0
/**
 * Prints a message to stdout
 * @param string $msg the message to print
 * @param boolean $verbose whether or not verbose output mode is enabled. If 
 * not enabled, message will not be printed (unless $err==TRUE)
 * @param string $file optional name of the file generating the message
 * @param int $line optional line number in the file generating the message
 * @param boolean $err if this message an error?
 * @return void
 */
function print_msg($msg, $verbose = FALSE, $file = NULL, $line = NULL, $err = FALSE)
{
    if ($verbose || $err) {
        printf("%-24s %-8s %-24s %s\n", date('m/d/Y H:i:s T'), run_time() . 's', str_replace('.php', '', basename($file ? $file : __FILE__)) . ':' . ($line ? $line : __LINE__), ($err ? 'ERROR: ' : '') . $msg);
    }
}
Esempio n. 6
0
<?php

if (!defined('IN_TG')) {
    exit('非法访问!');
}
//设置字符编码
header('Content-Type:text/html;charset=utf-8');
//设置访问硬路径,加快访问速度
define('ROOT_PATH', substr(dirname(__FILE__), 0, -8));
//检查php版本
if (PHP_VERSION < '4.4.0') {
    exit('PHP版本过低!');
}
require ROOT_PATH . '/includes/global.func.php';
//开始运行的时间
define('START_TIME', run_time());