Normalized on operating in float seconds rather than milliseconds.
This commit is contained in:
1 parent
624e282905
commit
1e75033f25
8 files changed
+15
-19
No files matched your search
@@ -23,7 +23,7 @@ interface Record_Interface {
|
||||
public function get_origin();
|
||||
|
||||
/**
|
||||
* @return int Record duration in milliseconds.
|
||||
* @return float Record duration in seconds.
|
||||
*/
|
||||
public function get_duration();
|
||||
|
||||
|
||||
@@ -43,7 +43,8 @@ class Sql_Record implements Record_Interface {
|
||||
* @return string
|
||||
*/
|
||||
public function get_description() {
|
||||
$duration = round( $this->duration );
|
||||
|
||||
$duration = round( $this->duration * 1000 ); // s to ms.
|
||||
|
||||
return "{$this->sql} – {$duration} ms";
|
||||
}
|
||||
@@ -56,7 +57,7 @@ class Sql_Record implements Record_Interface {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int Record duration in milliseconds.
|
||||
* @return float Record duration in seconds.
|
||||
*/
|
||||
public function get_duration() {
|
||||
return $this->duration;
|
||||
|
||||
@@ -32,9 +32,9 @@ class Sql_Record_Collector implements Record_Collector_Interface {
|
||||
global $wpdb;
|
||||
|
||||
if ( empty( $this->query_starts ) && ! empty( $wpdb->queries ) ) {
|
||||
$this->query_starts[ count( $wpdb->queries ) ] = microtime( true ) * 1000;
|
||||
$this->query_starts[ count( $wpdb->queries ) ] = microtime( true );
|
||||
} else {
|
||||
$this->query_starts[] = microtime( true ) * 1000;
|
||||
$this->query_starts[] = microtime( true );
|
||||
}
|
||||
|
||||
return $query;
|
||||
@@ -63,7 +63,6 @@ class Sql_Record_Collector implements Record_Collector_Interface {
|
||||
$category = 'query-write';
|
||||
}
|
||||
|
||||
$duration *= 1000;
|
||||
$last_query_end = $query_start + $duration;
|
||||
|
||||
$query_data[] = new Sql_Record( $sql, $query_start, $duration, $category );
|
||||
|
||||
@@ -36,7 +36,7 @@ class Stopwatch_Record implements Record_Interface {
|
||||
*/
|
||||
public function get_description() {
|
||||
|
||||
$duration = $this->stopwatch_event->getDuration();
|
||||
$duration = round( $this->stopwatch_event->getDuration() );
|
||||
$memory = $this->stopwatch_event->getMemory() / 1024 / 1024;
|
||||
|
||||
return "{$this->name} – {$duration} ms – {$memory} MB";
|
||||
@@ -46,14 +46,14 @@ class Stopwatch_Record implements Record_Interface {
|
||||
* @return float Timestamp of record start.
|
||||
*/
|
||||
public function get_origin() {
|
||||
return $this->stopwatch_event->getOrigin();
|
||||
return $this->stopwatch_event->getOrigin() / 1000; // ms to s.
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int Record duration in milliseconds.
|
||||
* @return float Record duration in seconds.
|
||||
*/
|
||||
public function get_duration() {
|
||||
return $this->stopwatch_event->getDuration();
|
||||
return $this->stopwatch_event->getDuration() / 1000; // ms to s.
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -26,7 +26,7 @@ class Timeline_Iterator implements \Iterator {
|
||||
|
||||
global $timestart;
|
||||
|
||||
$this->origin = $timestart * 1000;
|
||||
$this->origin = $timestart;
|
||||
$this->iterator = $iterator;
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ class Timeline_Iterator implements \Iterator {
|
||||
* Rewind to a topmost record set.
|
||||
*/
|
||||
public function rewind() {
|
||||
$this->total = microtime( true ) * 1000 - $this->origin;
|
||||
$this->total = microtime( true ) - $this->origin;
|
||||
$this->current = $this->iterator;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user