Пример #1
0
 public static function instance()
 {
     if (empty(self::$instance)) {
         $c = __CLASS__;
         self::$instance = new $c();
     }
     return self::$instance;
 }
Пример #2
0
 /**
  * 跟踪程序运行, 记录一些时间等情况。 
  * 
  * @param string $out 是否在页面输出
  */
 public static function time($key = null, $name = 'Tracer', $out = false)
 {
     if (empty(self::$timeTracer)) {
         self::$timeTracer = array(0 => array('name' => 'start.', 'time' => time()));
     }
     $now = microtime(true);
     // 时间跟踪器总数
     $count = !empty(self::$timeTracer) ? count(self::$timeTracer) : 0;
     // 距离上一个跟踪器所耗时间
     end(self::$timeTracer);
     $last_key = key(self::$timeTracer);
     $time = $now - self::$timeTracer[$last_key]['time'];
     // 添加进时间跟踪器
     $key = !empty($key) ? $key : $count;
     self::$timeTracer[$key] = array('name' => $key, 'time' => $now);
     if ($out) {
         $txt = "{$key} timer_{$count}: {$now} ,take {$time}";
         echo "<br>" . $txt . "<br>";
     }
 }
Пример #3
0
 public static function displayTracer(Tracer $Tracer, $separator = ' » ', $protect = true)
 {
     $traces = $Tracer->getTraces();
     if (!empty($traces)) {
         $output = '';
         foreach ($traces as $trace) {
             $name = $protect ? Security::noHtml($trace['name']) : $trace['name'];
             if ($trace['link']) {
                 $output .= Html::LinkTo($name, $trace['link']) . $separator;
             } else {
                 $output .= $name . $separator;
             }
         }
         return String::substr($output, 0, -String::length($separator));
     } else {
         return null;
     }
 }
Пример #4
0
 public function __construct($className)
 {
     $this->fileContent = Tracer::extract($className);
 }
Пример #5
0
<?php

/**
 * 系统启动程序入口
 *
 * @package Imp
 * @author 		Imp <*****@*****.**>
 * @copyright 	2015-2016 Imp All rights reserved.
 * @version 	1.0
 * @link
 */
!defined(APP_PATH) or die('undefine APP_PATH');
!defined(IMP_PATH) or die('undefine IMP_PATH');
!defined(ROOT_PATH) or die('undefine ROOT_PATH');
// 系统跟踪信息
$GLOBALS['_TRACE']['beginTime'] = microtime(true);
ob_start();
require __DIR__ . DIRECTORY_SEPARATOR . '../Imp.php';
// 添加时间跟踪器
//Tracer::time('start');
// 应用配置
$config = (require APP_PATH . 'Configs/Config.php');
// 创建应用
$app = Imp::createWebApplication($config, dirbane(__DIR__));
// 添加时间跟踪器
Tracer::time('end_create_app');
return $app;
// 注册自动装载方法
// spl_autoload_register(array('Imp', 'autoload'));