Added PHP and core load collector.
This commit is contained in:
1 parent
e74777c2a9
commit
4238509861
4 files changed
+59
-3
No files matched your search
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace Rarst\Laps\Record;
|
||||
|
||||
/**
|
||||
* Covers pre–plugin load time from available data.
|
||||
*/
|
||||
class Core_Load_Collector implements Record_Collector_Interface {
|
||||
|
||||
/** @var float $timeload */
|
||||
protected $timeload;
|
||||
|
||||
/**
|
||||
* Store core load end, plugin load start mark.
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->timeload = microtime( true );
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Record_Interface[]
|
||||
*/
|
||||
public function get_records() {
|
||||
|
||||
global $timestart;
|
||||
|
||||
$request_time = $_SERVER['REQUEST_TIME_FLOAT'];
|
||||
|
||||
return [
|
||||
new Record( 'PHP Load', $request_time, $timestart - $request_time, '', 'php' ),
|
||||
// TODO This includes network plugins on multisite, need conditional label if Laps is network–activated.
|
||||
new Record( 'Core and MU Plugins Load', $timestart, $this->timeload - $timestart, '', 'core' ),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -24,9 +24,7 @@ class Timeline_Iterator implements \Iterator {
|
||||
*/
|
||||
public function __construct( Recursive_Record_Iterator $iterator ) {
|
||||
|
||||
global $timestart;
|
||||
|
||||
$this->origin = $timestart;
|
||||
$this->origin = $_SERVER['REQUEST_TIME_FLOAT'];
|
||||
$this->iterator = $iterator;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user