From 839730497426f24c71b1e9aee14eb0c333a4abaa Mon Sep 17 00:00:00 2001 From: Daniel Bachhuber Date: Fri, 26 Aug 2016 13:00:32 -0700 Subject: [PATCH] Collapse the `execution_time` heading --- inc/class-command.php | 6 +++--- inc/class-formatter.php | 4 ++-- inc/class-logger.php | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/inc/class-command.php b/inc/class-command.php index 72046d7..ca74bd8 100644 --- a/inc/class-command.php +++ b/inc/class-command.php @@ -94,7 +94,7 @@ class Command { if ( $this->focus_scope ) { $fields = array( 'hook', - 'execution_time', + 'time', 'queries', 'cache', 'requests', @@ -102,7 +102,7 @@ class Command { } else if ( $this->focus_hook ) { $fields = array( 'callback', - 'execution_time', + 'time', 'queries', 'cache', 'requests', @@ -110,7 +110,7 @@ class Command { } else { $fields = array( 'scope', - 'execution_time', + 'time', 'queries', 'cache', 'hooks', diff --git a/inc/class-formatter.php b/inc/class-formatter.php index 19fb074..bf4da03 100644 --- a/inc/class-formatter.php +++ b/inc/class-formatter.php @@ -91,7 +91,7 @@ class Formatter { $values[ $i ] = rtrim( $new_value, '/ ' ); } else { $totals[ $i ] += $value; - if ( stripos( $fields[ $i ], '_time' ) ) { + if ( stripos( $fields[ $i ], '_time' ) || 'time' === $fields[ $i ] ) { $values[ $i ] = round( $value, 4 ) . 's'; } } @@ -99,7 +99,7 @@ class Formatter { $table->addRow( $values ); } foreach( $totals as $i => $value ) { - if ( stripos( $fields[ $i ], '_time' ) ) { + if ( stripos( $fields[ $i ], '_time' ) || 'time' === $fields[ $i ] ) { $totals[ $i ] = round( $value, 4 ) . 's'; } if ( is_array( $value ) ) { diff --git a/inc/class-logger.php b/inc/class-logger.php index d2376fc..bee7c2c 100644 --- a/inc/class-logger.php +++ b/inc/class-logger.php @@ -4,7 +4,7 @@ namespace runcommand\Profile; class Logger { - public $execution_time = 0; + public $time = 0; public $queries = array( 'count' => 0, 'time' => 0, @@ -58,7 +58,7 @@ class Logger { global $wpdb, $wp_object_cache; 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 ) ) { for ( $i = $this->query_offset; $i < count( $wpdb->queries ); $i++ ) {