In a cli report table, to properly compare numbers, columns with numbers should:
- be aligned right (
\STR_PAD_LEFT).
- use the same measuring unit (e.g. not
ms in one record, but µs in another record).
- ideally, a unit should be used where all values are > 1, so that big numbers visually stick out with additional digits to the left.
(for these last points I currently use --mode=throughput --time-unit=s as cli parameters)
For the first point, I found that the following addition in TableRenderer::render() has the desired effect for the main table:
$style = (new TableStyle())->setPadType(\STR_PAD_LEFT);
$nColumns = \count($object->columnNames());
for ($iCol = 2; $iCol < $nColumns; ++$iCol) {
$consoleTable->setColumnStyle($iCol, $style);
}
However, this is obviously the wrong place to do this.
I am hard-coding the rule that every column except the first two should be aligned right, which is true for the final overview table but not universally for every table.
What the code example shows is that the symfony console table component can align numbers right.
In a cli report table, to properly compare numbers, columns with numbers should:
\STR_PAD_LEFT).msin one record, butµsin another record).(for these last points I currently use
--mode=throughput --time-unit=sas cli parameters)For the first point, I found that the following addition in
TableRenderer::render()has the desired effect for the main table:However, this is obviously the wrong place to do this.
I am hard-coding the rule that every column except the first two should be aligned right, which is true for the final overview table but not universally for every table.
What the code example shows is that the symfony console table component can align numbers right.