Теперь у меня есть этот код:
Код: Выделить всё
private function debugBacktrace() {
$base = Base::instance()->get('dba');
$data = debug_backtrace();
foreach ($data as $row) {
$file = $row['file'] ?? null;
$function = $row['function'] ?? null;
$class = $row['class'] ?? null;
$date = new DateTime();
$dateFormatted = $date->format('Y-m-d H:i:s');
$existRecord = $base->exec("SELECT * FROM `pholus`.`debug_trace` WHERE `file` = '$file' AND `function` = '$function' AND `class` = '$class'");
if (!empty($existRecord)) {
$id = $existRecord[0]['id'];
$count = $existRecord[0]['count']+1;
$base->exec("UPDATE `pholus`.`debug_trace` SET `count` = $count, `last_update` = '$dateFormatted' WHERE `id` = $id;");
} else {
$base->exec("INSERT INTO `pholus`.`debug_trace` (`file`, `function`, `class`, `count`, `last_update`)
VALUES ('$file', '$function', '$class', 1, '$dateFormatted');");
}
}
}И результаты:
< img alt="введите описание изображения здесь" src="https://i.sstatic.net/6HP0gfSB.png" />
Единственный вопрос: является ли это оптимальным решением? Я не вижу здесь запущенных шаблонов (только php-файлы). Есть ли у f3 какое-либо собственное решение для профилирования?
Подробнее здесь: https://stackoverflow.com/questions/788 ... -framework
Мобильная версия