mirror of
https://hk.gh-proxy.com/https://github.com/wp-cli/profile-command.git
synced 2025-08-21 06:39:02 +08:00
Accurately display total percentages
This commit is contained in:
parent
7a62f86549
commit
a356003db9
1 changed files with 19 additions and 2 deletions
|
@ -70,9 +70,19 @@ class Formatter {
|
|||
continue;
|
||||
}
|
||||
if ( ! isset( $totals[ $i ] ) ) {
|
||||
$totals[ $i ] = 0;
|
||||
if ( stripos( $fields[ $i ], '_ratio' ) ) {
|
||||
$totals[ $i ] = array();
|
||||
} else {
|
||||
$totals[ $i ] = 0;
|
||||
}
|
||||
}
|
||||
if ( stripos( $fields[ $i ], '_ratio' ) ) {
|
||||
if ( ! is_null( $value ) ) {
|
||||
$totals[ $i ][] = $value;
|
||||
}
|
||||
} else {
|
||||
$totals[ $i ] += $value;
|
||||
}
|
||||
$totals[ $i ] += $value;
|
||||
if ( stripos( $fields[ $i ], '_time' ) || 'time' === $fields[ $i ] ) {
|
||||
$values[ $i ] = round( $value, 4 ) . 's';
|
||||
}
|
||||
|
@ -83,6 +93,13 @@ class Formatter {
|
|||
if ( stripos( $fields[ $i ], '_time' ) || 'time' === $fields[ $i ] ) {
|
||||
$totals[ $i ] = round( $value, 4 ) . 's';
|
||||
}
|
||||
if ( is_array( $value ) ) {
|
||||
if ( ! empty( $value ) ) {
|
||||
$totals[ $i ] = round( ( array_sum( $value ) / count( $value ) ), 2 ) . '%';
|
||||
} else {
|
||||
$totals[ $i ] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
$table->setFooters( $totals );
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue