forked from featherbb/featherbb
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDebug.php
More file actions
36 lines (31 loc) · 1.13 KB
/
Copy pathDebug.php
File metadata and controls
36 lines (31 loc) · 1.13 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
<?php
/**
* Copyright (C) 2015-2016 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\Utils;
class Debug
{
public static function get_queries()
{
if (empty(DB::get_query_log())) {
return null;
}
$data = array();
$data['raw'] = array_combine(DB::get_query_log()[0], DB::get_query_log()[1]);
$data['total_time'] = array_sum(array_keys($data['raw']));
return $data;
}
public static function get_info()
{
$data = array('exec_time' => (Utils::get_microtime() - Container::get('start')));
$data['nb_queries'] = (isset(DB::get_query_log()[0])) ? count(DB::get_query_log()[0]) : 'N/A';
$data['mem_usage'] = (function_exists('memory_get_usage')) ? Utils::file_size(memory_get_usage()) : 'N/A';
$data['mem_peak_usage'] = (function_exists('memory_get_peak_usage')) ? Utils::file_size(memory_get_peak_usage()) : 'N/A';
return $data;
}
}