Add more query time measurements

This commit is contained in:
Ruan 2015-07-03 22:03:53 +02:00
parent 84473a0cad
commit da57370385

View File

@ -32,8 +32,10 @@ $uuid_name_cache = [];
function get_name($uuid) { function get_name($uuid) {
global $conn, $table_history, $uuid_name_cache; global $conn, $table_history, $uuid_name_cache;
if (array_key_exists($uuid, $uuid_name_cache)) return $uuid_name_cache[$uuid]; if (array_key_exists($uuid, $uuid_name_cache)) return $uuid_name_cache[$uuid];
$time = microtime(true);
$stmt = $conn->prepare("SELECT name FROM " . $table_history . " WHERE uuid=? ORDER BY date DESC LIMIT 1"); $stmt = $conn->prepare("SELECT name FROM " . $table_history . " WHERE uuid=? ORDER BY date DESC LIMIT 1");
if ($stmt->execute(array($uuid)) && $row = $stmt->fetch()) { if ($stmt->execute(array($uuid)) && $row = $stmt->fetch()) {
echo('<!-- Query executed in ' . (microtime(true) - $time) . ' sec -->');
$banner = $row['name']; $banner = $row['name'];
$uuid_name_cache[$uuid] = $banner; $uuid_name_cache[$uuid] = $banner;
return $banner; return $banner;