<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                [TOC] * * * * * ## 1 調試源代碼(thinkphp\library\think\Debug.php) ~~~ protected static $info = []; protected static $mem = []; ~~~ ~~~ public static function remark($name, $value = '') { // 記錄時間和內存使用 self::$info[$name] = is_float($value) ? $value : microtime(true); if ('time' != $value) { self::$mem['mem'][$name] = is_float($value) ? $value : memory_get_usage(); self::$mem['peak'][$name] = memory_get_peak_usage(); } } ~~~ ~~~ public static function getRangeTime($start, $end, $dec = 6) { if (!isset(self::$info[$end])) { self::$info[$end] = microtime(true); } return number_format((self::$info[$end] - self::$info[$start]), $dec); } ~~~ ~~~ public static function getUseTime($dec = 6) { return number_format((microtime(true) - START_TIME), $dec); } ~~~ ~~~ public static function getThroughputRate() { return number_format(1 / self::getUseTime(), 2) . 'req/s'; } ~~~ ~~~ public static function getRangeMem($start, $end, $dec = 2) { if (!isset(self::$mem['mem'][$end])) { self::$mem['mem'][$end] = memory_get_usage(); } $size = self::$mem['mem'][$end] - self::$mem['mem'][$start]; $a = ['B', 'KB', 'MB', 'GB', 'TB']; $pos = 0; while ($size >= 1024) { $size /= 1024; $pos++; } return round($size, $dec) . " " . $a[$pos]; } ~~~ ~~~ public static function getUseMem($dec = 2) { $size = memory_get_usage() - START_MEM; $a = ['B', 'KB', 'MB', 'GB', 'TB']; $pos = 0; while ($size >= 1024) { $size /= 1024; $pos++; } return round($size, $dec) . " " . $a[$pos]; } ~~~ ~~~ public static function getMemPeak($start, $end, $dec = 2) { if (!isset(self::$mem['peak'][$end])) { self::$mem['peak'][$end] = memory_get_peak_usage(); } $size = self::$mem['peak'][$end] - self::$mem['peak'][$start]; $a = ['B', 'KB', 'MB', 'GB', 'TB']; $pos = 0; while ($size >= 1024) { $size /= 1024; $pos++; } return round($size, $dec) . " " . $a[$pos]; } ~~~ ~~~ public static function getFile($detail = false) { if ($detail) { $files = get_included_files(); $info = []; foreach ($files as $key => $file) { $info[] = $file . ' ( ' . number_format(filesize($file) / 1024, 2) . ' KB )'; } return $info; } return count(get_included_files()); } ~~~ ~~~ public static function dump($var, $echo = true, $label = null) { $label = (null === $label) ? '' : rtrim($label) . ':'; ob_start(); var_dump($var); $output = ob_get_clean(); $output = preg_replace('/\]\=\>\n(\s+)/m', '] => ', $output); if (IS_CLI) { $output = PHP_EOL . $label . $output . PHP_EOL; } else { if (!extension_loaded('xdebug')) { $output = htmlspecialchars($output, ENT_QUOTES); } $output = '<pre>' . $label . $output . '</pre>'; } if ($echo) { echo ($output); return null; } else { return $output; } } ~~~ ## 2 文件分析 1 靜態變量 `$info:` 開始標簽和結束標簽之間的時間間隔信息 `$mem:`開始標簽和結束標簽之間的內存消耗信息 2 `public static function remark($name, $value = ''){}` 記錄時間間隔和內存使用情況 3 `public static function getRangeTime($start, $end, $dec = 6){}` 統計某個區間的時間間隔 > $start:統計開始標簽 > $end:統計結束標簽 > $dec:小數位 4 `public static function getUseTime($dec = 6){}` 統計從開始(START_TIME)到當前的時間 > $dec:小數位 5 `public static function getThroughputRate(){}` 從開始到當前時間的吞吐率情況 6 `public static function getRangeMem($start, $end, $dec = 2){}` 統計某個區間的內存使用情況 > $start:統計開始標簽 > $end:統計結束標簽 > $dec:小數位 7 `public static function getUseMem($dec = 2)` 統計從開始到當前時間的內存使用情況 > $dec:小數位 8 `public static function getMemPeak($start, $end, $dec = 2){}` 統計某個區間的內存峰值情況 > $start:統計開始標簽 > $end:統計結束標簽 > $dec:小數位 9 `public static function getFile($detail = false){}` 獲取文件加載信息 > $detail 是否包含詳細信息 10 `public static function dump($var, $echo = true, $label = null){}` 瀏覽器友好變量輸出 > $var 輸出數據信息 > $echo 返回還是輸出 > $label 標簽控制 ## 3 使用方法 > >1 快捷操作 helper.php輔助函數中的G()封裝了調試接口,分析見另:(helper.php)輔助函數 dump() 函數調用Debug::dump(),實現了瀏覽器友好變量輸出 >>2 全局變量 base.php文件定義了系統開始時間和內存使用情況 START_TIME 開始運行時間 START_MEM 開始內存消耗 ## 4 總結 Debug.php文件在開發調試中用來統計性能。 包括時間消耗,內存消耗。 還有環境友好變量輸出
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看