-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathDebug.php
More file actions
37 lines (32 loc) · 1.14 KB
/
Debug.php
File metadata and controls
37 lines (32 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
/**
* Copyright (C) 2015-2019 FeatherBB
* based on code by (C) 2008-2015 FluxBB
* and Rickard Andersson (C) 2002-2008 PunBB
* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
*/
namespace FeatherBB\Model;
use FeatherBB\Core\Database as DB;
use FeatherBB\Core\Interfaces\Container;
use FeatherBB\Core\Utils;
class Debug
{
public static function getQueries()
{
if (empty(DB::getQueryLog())) {
return null;
}
$data = [];
$data['raw'] = array_combine(DB::getQueryLog()[0], DB::getQueryLog()[1]);
$data['total_time'] = array_sum(array_keys($data['raw']));
return $data;
}
public static function getInfo()
{
$data = ['exec_time' => (Utils::getMicrotime() - Container::get('start'))];
$data['nb_queries'] = (isset(DB::getQueryLog()[0])) ? count(DB::getQueryLog()[0]) : 'N/A';
$data['mem_usage'] = (function_exists('memory_get_usage')) ? Utils::fileSize(memory_get_usage()) : 'N/A';
$data['mem_peak_usage'] = (function_exists('memory_get_peak_usage')) ? Utils::fileSize(memory_get_peak_usage()) : 'N/A';
return $data;
}
}