當前位置: 首頁>>代碼示例>>PHP>>正文


PHP SqlFormatter::getCacheStats方法代碼示例

本文整理匯總了PHP中SqlFormatter::getCacheStats方法的典型用法代碼示例。如果您正苦於以下問題:PHP SqlFormatter::getCacheStats方法的具體用法?PHP SqlFormatter::getCacheStats怎麽用?PHP SqlFormatter::getCacheStats使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在SqlFormatter的用法示例。


在下文中一共展示了SqlFormatter::getCacheStats方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: file

require '../lib/SqlFormatter.php';
//this is the default value
//set to '0' to disable caching
//a value between 10 and 20 seems to give the best result
SqlFormatter::$max_cachekey_size = 15;
$contents = file('sql.sql');
//track time and memory usage
$start = microtime(true);
$ustart = memory_get_usage(true);
//track number of queries and size of queries
$queries = 0;
$bytes = 0;
//format each query 3 times
for ($i = 0; $i < 3; $i++) {
    foreach ($contents as $query) {
        //this tries to mix up the queries so we aren't just running the same thing a bunch of times
        $query = str_replace('tablename', rand(1, 10000), $query);
        //do formatting and highlighting
        SqlFormatter::format($query);
        $queries++;
        $bytes += strlen($query);
    }
}
$uend = memory_get_usage(true);
$end = microtime(true);
echo "<p>Formatted {$queries} queries.</p>";
echo "<p>Average query length of " . number_format($bytes / $queries, 5) . " characters</p>";
echo "<p>Took " . number_format($end - $start, 5) . " seconds total, " . number_format(($end - $start) / $queries, 5) . " seconds per query, " . number_format(1000 * ($end - $start) / $bytes, 5) . " seconds per 1000 characters</p>";
echo "<p>Used " . number_format($uend - $ustart) . " bytes of memory</p>";
echo "<h3>Cache Stats</h3><pre>" . print_r(SqlFormatter::getCacheStats(), true) . "</pre>";
開發者ID:TeamA-ict,項目名稱:TeamA,代碼行數:30,代碼來源:performance.php

示例2: testCacheStats

 function testCacheStats()
 {
     $stats = SqlFormatter::getCacheStats();
     $this->assertGreaterThan(1, $stats['hits']);
 }
開發者ID:PieterSwitten,項目名稱:webandmobile,代碼行數:5,代碼來源:SqlFormatterTest.php


注:本文中的SqlFormatter::getCacheStats方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。