-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdebug.php
41 lines (35 loc) · 915 Bytes
/
debug.php
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
38
39
40
41
<?php
function myMicrotime($get_as_float = true) {
list($msec, $sec) = explode(" ", microtime());
$time = $sec . substr($msec, 1);
return $as_float === false ? $time : (float)$time;
}
function timer(&$array, $descrition = '') {
if( !is_array($array) ) $array = array();
if( $descrition != '' ) $array['DESC'] = $descrition;
if( !key_exists('START', $array) ) {
$array['START'] = myMicrotime();
} else {
$array['END'] = myMicrotime();
$array['FULL_TIME'] = $array['END'] - $array['START'];
}
}
function ___save_debug($data='', $desc=''){
if( !empty($data) && $data!='' ) {
if( is_array($data) || is_object($data) ) {
$data = print_r($data, true);
}
}
$fp = fopen('__dbg', 'a');
fwrite($fp, "\n$desc: $data\n");
fclose($fp);
};
function debug_time($finish=false)
{
static $start_time;
if(!$finish)
$start_time = microtime(true);
else
return microtime(true) - $start_time;
}
?>