mirror of
https://hk.gh-proxy.com/https://github.com/wp-cli/profile-command.git
synced 2025-08-21 06:39:01 +08:00
Ensure the last step to a stage is logged appropriately
This commit is contained in:
parent
3a0b093984
commit
b31f5c39fa
3 changed files with 21 additions and 0 deletions
|
@ -18,4 +18,5 @@ Feature: Profile the template render stage
|
||||||
| loop_end |
|
| loop_end |
|
||||||
| |
|
| |
|
||||||
| wp_footer |
|
| wp_footer |
|
||||||
|
| |
|
||||||
| total |
|
| total |
|
||||||
|
|
|
@ -217,6 +217,10 @@ class Command {
|
||||||
$pseudo_hook = "before {$this->stage_hooks[$key+1]}";
|
$pseudo_hook = "before {$this->stage_hooks[$key+1]}";
|
||||||
$this->loggers[ $pseudo_hook ] = new Logger( 'hook', '' );
|
$this->loggers[ $pseudo_hook ] = new Logger( 'hook', '' );
|
||||||
$this->loggers[ $pseudo_hook ]->start();
|
$this->loggers[ $pseudo_hook ]->start();
|
||||||
|
} else {
|
||||||
|
$pseudo_hook = 'wp_profile_last_hook';
|
||||||
|
$this->loggers[ $pseudo_hook ] = new Logger( 'hook', '' );
|
||||||
|
$this->loggers[ $pseudo_hook ]->start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -267,6 +271,9 @@ class Command {
|
||||||
} catch( \Exception $e ) {
|
} catch( \Exception $e ) {
|
||||||
// pass through
|
// pass through
|
||||||
}
|
}
|
||||||
|
if ( isset( $this->loggers['wp_profile_last_hook'] ) && $this->loggers['wp_profile_last_hook']->running() ) {
|
||||||
|
$this->loggers['wp_profile_last_hook']->stop();
|
||||||
|
}
|
||||||
if ( ! $this->focus_stage && ! $this->focus_hook ) {
|
if ( ! $this->focus_stage && ! $this->focus_hook ) {
|
||||||
$logger->stop();
|
$logger->stop();
|
||||||
$this->loggers[] = $logger;
|
$this->loggers[] = $logger;
|
||||||
|
@ -290,6 +297,9 @@ class Command {
|
||||||
} catch( \Exception $e ) {
|
} catch( \Exception $e ) {
|
||||||
// pass through
|
// pass through
|
||||||
}
|
}
|
||||||
|
if ( isset( $this->loggers['wp_profile_last_hook'] ) && $this->loggers['wp_profile_last_hook']->running() ) {
|
||||||
|
$this->loggers['wp_profile_last_hook']->stop();
|
||||||
|
}
|
||||||
if ( ! $this->focus_stage && ! $this->focus_hook ) {
|
if ( ! $this->focus_stage && ! $this->focus_hook ) {
|
||||||
$logger->stop();
|
$logger->stop();
|
||||||
$this->loggers[] = $logger;
|
$this->loggers[] = $logger;
|
||||||
|
@ -322,6 +332,9 @@ class Command {
|
||||||
} catch( \Exception $e ) {
|
} catch( \Exception $e ) {
|
||||||
// pass through
|
// pass through
|
||||||
}
|
}
|
||||||
|
if ( isset( $this->loggers['wp_profile_last_hook'] ) && $this->loggers['wp_profile_last_hook']->running() ) {
|
||||||
|
$this->loggers['wp_profile_last_hook']->stop();
|
||||||
|
}
|
||||||
ob_get_clean();
|
ob_get_clean();
|
||||||
if ( ! $this->focus_stage && ! $this->focus_hook ) {
|
if ( ! $this->focus_stage && ! $this->focus_hook ) {
|
||||||
$logger->stop();
|
$logger->stop();
|
||||||
|
|
|
@ -43,6 +43,13 @@ class Logger {
|
||||||
$this->cache_miss_offset = ! empty( $wp_object_cache->cache_misses ) ? $wp_object_cache->cache_misses : 0;
|
$this->cache_miss_offset = ! empty( $wp_object_cache->cache_misses ) ? $wp_object_cache->cache_misses : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether or not the logger is running
|
||||||
|
*/
|
||||||
|
public function running() {
|
||||||
|
return ! is_null( $this->start_time );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stop this logger
|
* Stop this logger
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue