mirror of
https://hk.gh-proxy.com/https://github.com/wp-cli/profile-command.git
synced 2025-08-21 06:38:49 +08:00
Merge pull request #34 from runcommand/collapse-execution-time
Collapse the `execution_time` heading
This commit is contained in:
commit
157ddfb73c
3 changed files with 7 additions and 7 deletions
|
@ -94,7 +94,7 @@ class Command {
|
||||||
if ( $this->focus_scope ) {
|
if ( $this->focus_scope ) {
|
||||||
$fields = array(
|
$fields = array(
|
||||||
'hook',
|
'hook',
|
||||||
'execution_time',
|
'time',
|
||||||
'queries',
|
'queries',
|
||||||
'cache',
|
'cache',
|
||||||
'requests',
|
'requests',
|
||||||
|
@ -102,7 +102,7 @@ class Command {
|
||||||
} else if ( $this->focus_hook ) {
|
} else if ( $this->focus_hook ) {
|
||||||
$fields = array(
|
$fields = array(
|
||||||
'callback',
|
'callback',
|
||||||
'execution_time',
|
'time',
|
||||||
'queries',
|
'queries',
|
||||||
'cache',
|
'cache',
|
||||||
'requests',
|
'requests',
|
||||||
|
@ -110,7 +110,7 @@ class Command {
|
||||||
} else {
|
} else {
|
||||||
$fields = array(
|
$fields = array(
|
||||||
'scope',
|
'scope',
|
||||||
'execution_time',
|
'time',
|
||||||
'queries',
|
'queries',
|
||||||
'cache',
|
'cache',
|
||||||
'hooks',
|
'hooks',
|
||||||
|
|
|
@ -91,7 +91,7 @@ class Formatter {
|
||||||
$values[ $i ] = rtrim( $new_value, '/ ' );
|
$values[ $i ] = rtrim( $new_value, '/ ' );
|
||||||
} else {
|
} else {
|
||||||
$totals[ $i ] += $value;
|
$totals[ $i ] += $value;
|
||||||
if ( stripos( $fields[ $i ], '_time' ) ) {
|
if ( stripos( $fields[ $i ], '_time' ) || 'time' === $fields[ $i ] ) {
|
||||||
$values[ $i ] = round( $value, 4 ) . 's';
|
$values[ $i ] = round( $value, 4 ) . 's';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ class Formatter {
|
||||||
$table->addRow( $values );
|
$table->addRow( $values );
|
||||||
}
|
}
|
||||||
foreach( $totals as $i => $value ) {
|
foreach( $totals as $i => $value ) {
|
||||||
if ( stripos( $fields[ $i ], '_time' ) ) {
|
if ( stripos( $fields[ $i ], '_time' ) || 'time' === $fields[ $i ] ) {
|
||||||
$totals[ $i ] = round( $value, 4 ) . 's';
|
$totals[ $i ] = round( $value, 4 ) . 's';
|
||||||
}
|
}
|
||||||
if ( is_array( $value ) ) {
|
if ( is_array( $value ) ) {
|
||||||
|
|
|
@ -4,7 +4,7 @@ namespace runcommand\Profile;
|
||||||
|
|
||||||
class Logger {
|
class Logger {
|
||||||
|
|
||||||
public $execution_time = 0;
|
public $time = 0;
|
||||||
public $queries = array(
|
public $queries = array(
|
||||||
'count' => 0,
|
'count' => 0,
|
||||||
'time' => 0,
|
'time' => 0,
|
||||||
|
@ -58,7 +58,7 @@ class Logger {
|
||||||
global $wpdb, $wp_object_cache;
|
global $wpdb, $wp_object_cache;
|
||||||
|
|
||||||
if ( ! is_null( $this->start_time ) ) {
|
if ( ! is_null( $this->start_time ) ) {
|
||||||
$this->execution_time += microtime( true ) - $this->start_time;
|
$this->time += microtime( true ) - $this->start_time;
|
||||||
}
|
}
|
||||||
if ( ! is_null( $this->query_offset ) ) {
|
if ( ! is_null( $this->query_offset ) ) {
|
||||||
for ( $i = $this->query_offset; $i < count( $wpdb->queries ); $i++ ) {
|
for ( $i = $this->query_offset; $i < count( $wpdb->queries ); $i++ ) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue