(
alerts: Alert[],
benchName: string,
curSuite: Benchmark,
prevSuite: Benchmark,
threshold: number,
cc: string[],
)
| 199 | } |
| 200 | |
| 201 | function buildAlertComment( |
| 202 | alerts: Alert[], |
| 203 | benchName: string, |
| 204 | curSuite: Benchmark, |
| 205 | prevSuite: Benchmark, |
| 206 | threshold: number, |
| 207 | cc: string[], |
| 208 | ): string { |
| 209 | // Do not show benchmark name if it is the default value 'Benchmark'. |
| 210 | const benchmarkText = benchName === 'Benchmark' ? '' : ` **'${benchName}'**`; |
| 211 | const title = threshold === 0 ? '# Performance Report' : '# :warning: **Performance Alert** :warning:'; |
| 212 | const thresholdString = floatStr(threshold); |
| 213 | const lines = [ |
| 214 | title, |
| 215 | '', |
| 216 | `Possible performance regression was detected for benchmark${benchmarkText}.`, |
| 217 | `Benchmark result of this commit is worse than the previous benchmark result exceeding threshold \`${thresholdString}\`.`, |
| 218 | '', |
| 219 | `| Benchmark suite | Current: ${curSuite.commit.id} | Previous: ${prevSuite.commit.id} | Ratio |`, |
| 220 | '|-|-|-|-|', |
| 221 | ]; |
| 222 | |
| 223 | for (const alert of alerts) { |
| 224 | const { current, prev, ratio } = alert; |
| 225 | const line = `| \`${current.name}\` | ${strVal(current)} | ${strVal(prev)} | \`${floatStr(ratio)}\` |`; |
| 226 | lines.push(line); |
| 227 | } |
| 228 | |
| 229 | // Footer |
| 230 | lines.push('', commentFooter()); |
| 231 | |
| 232 | if (cc.length > 0) { |
| 233 | lines.push('', `CC: ${cc.join(' ')}`); |
| 234 | } |
| 235 | |
| 236 | return lines.join('\n'); |
| 237 | } |
| 238 | |
| 239 | async function leaveComment(commitId: string, body: string, token: string) { |
| 240 | core.debug('Sending comment:\n' + body); |
no test coverage detected