Improve formatting in test/parse_benchmark_output.py (#18047)
New:
```
Node.js_no_stack_check Node.js_with_stack_check
base64 1.000 0.972
conditionals 1.000 1.096
copy 1.000 1.003
corrections 1.000 0.982
corrections64 1.000 1.004
fannkuch 1.000 1.004
fasta_float 1.000 1.002
havlak 1.000 1.025
ifs 1.000 0.962
matrix_multiply 1.000 1.021
```
Old:
```
Node.js_no_stack_check Node.js_with_stack_check
base64 1.0 0.9715909090909092
conditionals 1.0 1.096219035202086
copy 1.0 1.0028841716658976
corrections 1.0 0.9817155149233665
corrections64 1.0 1.0042210283960094
fannkuch 1.0 1.004495825305074
fasta_float 1.0 1.001837993960877
havlak 1.0 1.0250723240115718
ifs 1.0 0.9619738238415282
matrix_multiply 1.0 1.0212443095599393
```diff --git a/test/parse_benchmark_output.py b/test/parse_benchmark_output.py
old mode 100644
new mode 100755
index 6354fa8..d76c179
--- a/test/parse_benchmark_output.py
+++ b/test/parse_benchmark_output.py
@@ -54,13 +54,20 @@
for i in range(1, len(line)):
line[i] = line[i] / base
+col0_width = max(len(r[0]) for r in matrix)
+
# filter results
result = []
-for line in matrix:
- if len(line) != len(matrix[0]):
- print('warning: not enough results, skipping line:', line[0])
+for i, row in enumerate(matrix):
+ if len(row) != len(matrix[0]):
+ print('warning: not enough results, skipping row:', row[0])
else:
- result += ['\t'.join([str(x) for x in line])]
+ line = '%*s ' % (col0_width, row[0])
+ if i == 0:
+ line += '\t'.join([str(x) for x in row[1:]])
+ else:
+ line += '\t'.join(['%.3f' % x for x in row[1:]])
+ result.append(line)
# print results
print()