本文整理汇总了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>";
示例2: testCacheStats
function testCacheStats()
{
$stats = SqlFormatter::getCacheStats();
$this->assertGreaterThan(1, $stats['hits']);
}