mirror of
https://hk.gh-proxy.com/https://github.com/wp-cli/profile-command.git
synced 2025-08-21 06:39:02 +08:00
Log request count and time
This commit is contained in:
parent
5e84ef9022
commit
2b5a3c6097
2 changed files with 45 additions and 0 deletions
|
@ -9,11 +9,14 @@ class Logger {
|
|||
public $query_time = 0;
|
||||
public $hook_count = 0;
|
||||
public $hook_time = 0;
|
||||
public $request_count = 0;
|
||||
public $request_time = 0;
|
||||
|
||||
private $start_time = null;
|
||||
private $query_offset = null;
|
||||
private $hook_start_time = null;
|
||||
private $hook_depth = 0;
|
||||
private $request_start_time = null;
|
||||
|
||||
public static $active_loggers = array();
|
||||
|
||||
|
@ -83,4 +86,22 @@ class Logger {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Start this logger's request timer
|
||||
*/
|
||||
public function start_request_timer() {
|
||||
$this->request_count++;
|
||||
$this->request_start_time = microtime( true );
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop this logger's request timer
|
||||
*/
|
||||
public function stop_request_timer() {
|
||||
if ( ! is_null( $this->request_start_time ) ) {
|
||||
$this->request_time += microtime( true ) - $this->request_start_time;
|
||||
}
|
||||
$this->request_start_time = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue