Skip to content

Commit 8b5a7fa

Browse files
committed
tune CI metrics configs
1 parent 84f2b50 commit 8b5a7fa

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

packages/replay/metrics/configs/ci/collect.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ const result = await collector.execute({
3939

4040
const cpuUsage = stats.mean(MetricsStats.cpu)!;
4141
if (cpuUsage > 0.85) {
42+
// Note: complexity on the "JankTest" is defined by the `minimum = ...,` setting in app.js - specifying the number of animated elements.
4243
console.warn(`✗ | Discarding results because CPU usage is too high and may be inaccurate: ${(cpuUsage * 100).toFixed(2)} %.`,
4344
'Consider simplifying the scenario or changing the CPU throttling factor.');
4445
return false;

packages/replay/metrics/src/results/analyzer.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,16 @@ class AnalyzerItemNumberValue implements AnalyzerItemValue {
8383

8484
public get diff(): string {
8585
const diff = this._b - this._a;
86-
const str = this._withUnit(diff);
86+
const str = this._withUnit(diff, true);
8787
return diff > 0 ? `+${str}` : str;
8888
}
8989

90-
private _withUnit(value: number): string {
90+
private _withUnit(value: number, isDiff: boolean = false): string {
9191
switch (this._unit) {
9292
case AnalyzerItemUnit.bytes:
9393
return filesize(value) as string;
9494
case AnalyzerItemUnit.ratio:
95-
return `${(value * 100).toFixed(2)} %`;
95+
return `${(value * 100).toFixed(2)} ${isDiff ? 'pp' : '%'}`;
9696
default:
9797
return `${value.toFixed(2)} ${AnalyzerItemUnit[this._unit]}`;
9898
}

packages/replay/metrics/src/results/pr-comment.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Result } from './result.js';
44
import { ResultSetItem } from './results-set.js';
55

66
function trimIndent(str: string): string {
7-
return str.split('\n').map(s => s.trim()).join('\n');
7+
return str.trim().split('\n').map(s => s.trim()).join('\n');
88
}
99

1010
function printableMetricName(metric: AnalyzerItemMetric): string {
@@ -32,7 +32,15 @@ export class PrCommentBuilder {
3232
}
3333

3434
public get body(): string {
35-
return trimIndent(this._buffer);
35+
const now = new Date();
36+
return trimIndent(`
37+
${this._buffer}
38+
<hr />
39+
<div align="right">
40+
CPU usage difference is shown as <a href="https://en.wikipedia.org/wiki/Percentage_point">percentage points</a>. <br />
41+
Last updated: <time datetime="${now.toISOString()}">${now.toUTCString()}</time>
42+
</div>
43+
`);
3644
}
3745

3846
public async addCurrentResult(analysis: Analysis, otherName: string): Promise<void> {

packages/replay/metrics/test-apps/jank/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ document.addEventListener("DOMContentLoaded", function() {
2525
incrementor = 10,
2626
distance = 3,
2727
frame,
28-
minimum = 30,
28+
minimum = 70,
2929
subtract = document.querySelector('.subtract'),
3030
add = document.querySelector('.add');
3131

0 commit comments

Comments
 (0)