Skip to content

Commit 97749ab

Browse files
committed
ci: benchmark: Vertical padding for the charts
1 parent 0ef95ca commit 97749ab

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

ci/github-actions/illustrate-benchmark-reports.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ const xmlHeader = '<?xml version="1.0" encoding="utf-8" ?>'
99
const xmlns = 'http://www.w3.org/2000/svg'
1010
const xlink = 'http://www.w3.org/1999/xlink'
1111

12-
const padding = 10
12+
const hPadding = 10
13+
const vPadding = 5
1314
const charWidth = 9
1415
const barColumnWidth = 512
1516
const numberLength = 6
@@ -26,22 +27,22 @@ const fontFamily = 'Consolas, Menlo, monospace'
2627

2728
function renderReport(report: Report) {
2829
assert(report.results.length > 0, 'There must be at least 1 report')
29-
const viewBoxHeight = report.results.length * rowHeight
30+
const viewBoxHeight = report.results.length * rowHeight + 2 * vPadding
3031
const labelLengths = report.results.map(unit => unit.command.length)
3132
const labelColumnWidth = Math.max(...labelLengths) * charWidth
3233
const values = report.results.map(unit => unit.mean)
3334
const maxValue = Math.max(...values)
34-
const viewBoxWidth = labelColumnWidth + barColumnWidth + 5 * padding + numberColumnWidth
35+
const viewBoxWidth = labelColumnWidth + barColumnWidth + 5 * hPadding + numberColumnWidth
3536
const shapes = report.results
3637
.map((unit, index) => ({
3738
...unit,
3839
index,
3940
name: unit.command.split(' ')[0].trim(),
40-
labelX: padding,
41-
barX: padding + labelColumnWidth + padding,
42-
numberX: padding + labelColumnWidth + padding + barColumnWidth + padding,
43-
textY: (index + 0.8) * rowHeight,
44-
barY: index * rowHeight,
41+
labelX: hPadding,
42+
barX: hPadding + labelColumnWidth + hPadding,
43+
numberX: hPadding + labelColumnWidth + hPadding + barColumnWidth + hPadding,
44+
textY: vPadding + (index + 0.8) * rowHeight,
45+
barY: vPadding + index * rowHeight,
4546
labelWidth: unit.command.length * charWidth,
4647
barWidth: unit.mean * barColumnWidth / maxValue,
4748
numberContent: String(unit.mean).slice(0, numberLength - 1) + 's',

0 commit comments

Comments
 (0)