123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- <?php
- require '../lib/SqlFormatter.php';
-
-
-
- SqlFormatter::$max_cachekey_size = 15;
-
- $contents = file('sql.sql');
-
-
- $start = microtime(true);
- $ustart = memory_get_usage(true);
-
-
- $queries = 0;
- $bytes = 0;
-
-
- for ($i =0; $i<3; $i++) {
- foreach ($contents as $query) {
-
- $query = str_replace('tablename', rand(1, 10000), $query);
-
-
- 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>";
-
|