From 4f07e96d62cc031d75c108b21f5ad91414c1945a Mon Sep 17 00:00:00 2001 From: Felipe Elia Date: Wed, 11 Dec 2024 07:51:50 -0300 Subject: [PATCH] Better number formatting Co-authored-by: columbian-chris --- includes/classes/Command.php | 8 +++++--- includes/partials/stats-page.php | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/includes/classes/Command.php b/includes/classes/Command.php index 0c978a849f..0ae7e9bcd8 100644 --- a/includes/classes/Command.php +++ b/includes/classes/Command.php @@ -1335,9 +1335,11 @@ public function index_output( $message, $args, $index_meta, $context ) { $time_elapsed = Utility::timer_stop( 2 ); WP_CLI::log( WP_CLI::colorize( '%Y' . esc_html__( 'Time elapsed: ', 'elasticpress' ) . '%N' . Utility::timer_format( $time_elapsed ) . $time_elapsed_diff ) ); - $current_memory = round( memory_get_usage() / 1024 / 1024, 2 ) . 'mb'; - $peak_memory = ' (Peak: ' . round( memory_get_peak_usage() / 1024 / 1024, 2 ) . 'mb)'; - WP_CLI::log( WP_CLI::colorize( '%Y' . esc_html__( 'Memory Usage: ', 'elasticpress' ) . '%N' . $current_memory . $peak_memory ) ); + $current_memory = memory_get_usage() / 1024 / 1024; + $current_memory = ( $current_memory > 1000 ) ? round( $current_memory / 1024, 2 ) . 'gb' : round( $current_memory, 2 ) . 'mb'; + $peak_memory = memory_get_peak_usage() / 1024 / 1024; + $peak_memory = ( $peak_memory > 1000 ) ? round( $peak_memory / 1024, 2 ) . 'gb' : round( $peak_memory, 2 ) . 'mb'; + WP_CLI::log( WP_CLI::colorize( '%Y' . esc_html__( 'Memory Usage: ', 'elasticpress' ) . '%N' . $current_memory . ' (Peak: ' . $peak_memory . ')' ) ); } } } diff --git a/includes/partials/stats-page.php b/includes/partials/stats-page.php index 6a63ca0ac8..63c43af3b0 100644 --- a/includes/partials/stats-page.php +++ b/includes/partials/stats-page.php @@ -84,7 +84,7 @@

-

+