<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國際加速解決方案。 廣告
                # 基準測試類 CodeIgniter 有一個一直都是啟用狀態的基準測試類,用于計算兩個標記點之間的時間差。 注解 該類是由系統自動加載,無需手動加載。 另外,基準測試總是在框架被調用的那一刻開始,在輸出類向瀏覽器發送最終的視圖之前結束。 這樣可以顯示出整個系統執行的精確時間。 [TOC] ## 使用基準測試類 基準測試類可以在你的?[控制器](http://codeigniter.org.cn/user_guide/general/controllers.html)、[視圖](http://codeigniter.org.cn/user_guide/general/views.html)?以及?[模型](http://codeigniter.org.cn/user_guide/general/models.html)?中使用。 使用流程如下: 1. 標記一個起始點 2. 標記一個結束點 3. 使用 elapsed_time 函數計算時間差。 這里是個真實的代碼示例: ~~~ $this->benchmark->mark('code_start'); // Some code happens here $this->benchmark->mark('code_end'); echo $this->benchmark->elapsed_time('code_start', 'code_end'); ~~~ > 注解 > "code_start" 和 "code_end" 這兩個單詞是隨意的,它們只是兩個用于標記 的單詞而已,你可以任意使用其他你想使用的單詞,另外,你也可以設置多個標記點。 看如下示例: ~~~ $this->benchmark->mark('dog'); // Some code happens here $this->benchmark->mark('cat'); // More code happens here $this->benchmark->mark('bird'); echo $this->benchmark->elapsed_time('dog', 'cat'); echo $this->benchmark->elapsed_time('cat', 'bird'); echo $this->benchmark->elapsed_time('dog', 'bird'); ~~~ ### 在 性能分析器 中使用基準測試點 如果你希望你的基準測試數據顯示在?[性能分析器](http://codeigniter.org.cn/user_guide/general/profiling.html)?中, 那么你的標記點就需要成對出現,而且標記點名稱需要以 _start 和 _end 結束, 每一對的標記點名稱應該一致。例如: ~~~ $this->benchmark->mark('my_mark_start'); // Some code happens here... $this->benchmark->mark('my_mark_end'); $this->benchmark->mark('another_mark_start'); // Some more code happens here... $this->benchmark->mark('another_mark_end'); ~~~ 閱讀?[性能分析器](http://codeigniter.org.cn/user_guide/general/profiling.html)?頁面了解更多信息。 ### 顯示總執行時間 如果你想顯示從 CodeIgniter 運行開始到最終結果輸出到瀏覽器之間花費的總時間, 只需簡單的將下面這行代碼放入你的視圖文件中: ~~~ <?php echo $this->benchmark->elapsed_time();?> ~~~ 你大概也注意到了,這個方法和上面例子中的介紹的那個計算兩個標記點之間時間差的方法是一樣的, 只是不帶任何參數。當不設參數時,CodeIgniter 在向瀏覽器輸出最終結果之前不會停止計時,所以 無論你在哪里使用該方法,輸出的計時結果都是總執行時間。 如果你不喜歡純 PHP 語法的話,也可以在你的視圖中使用另一種偽變量的方式來顯示總執行時間: ~~~ {elapsed_time} ~~~ > 注解 > 如果你想在你的控制器方法中進行基準測試,你需要設置你自己的標記起始點和結束點。 ### 顯示內存占用 如果你的 PHP 在安裝時使用了 --enable-memory-limit 參數進行編譯,你就可以在你的視圖文件中 使用下面這行代碼來顯示整個系統所占用的內存大小: ~~~ <?php echo $this->benchmark->memory_usage();?> ~~~ > 注解 > 這個方法只能在視圖文件中使用,顯示的結果代表整個應用所占用的內存大小。 如果你不喜歡純 PHP 語法的話,也可以在你的視圖中使用另一種偽變量的方式來顯示占用的內存大小: ~~~ {memory_usage} ~~~ ## 類參考 classCI_Benchmark >[info] ### mark($name) 參數: * **$name**?(string) -- the name you wish to assign to your marker 返回類型: void 設置一個基準測試的標記點。 elapsed_time([$point1 = ''[,?$point2 = ''[,?$decimals = 4]]]) 參數: * **$point1**?(string) -- a particular marked point * **$point2**?(string) -- a particular marked point * **$decimals**?(int) -- number of decimal places for precision 返回: Elapsed time 返回類型: string 計算并返回兩個標記點之間的時間差。 如果第一個參數為空,方法將返回?{elapsed_time}?偽變量。這用于在視圖中 顯示整個系統的執行時間,輸出類將在最終輸出時使用真實的總執行時間替換掉這個偽變量。 >[info] ### memory_usage() 返回: Memory usage info 返回類型: string 只是簡單的返回?{memory_usage}?偽變量。 該方法可以在視圖的任意位置使用,直到最終輸出頁面時?[輸出類](http://codeigniter.org.cn/user_guide/libraries/output.html)?才會將真實的值替換掉這個偽變量。
                  <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>

                              哎呀哎呀视频在线观看