Skip to content

Commit 60d0b62

Browse files
committed
fix and improve metrics analyzer console output
1 parent d132f35 commit 60d0b62

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { filesize } from 'filesize';
22

33
import { GitHash } from '../util/git.js';
4+
import { JsonStringify } from '../util/json.js';
45
import { AnalyticsFunction, MetricsStats, NumberProvider } from './metrics-stats.js';
56
import { Result } from './result.js';
67
import { ResultsSet } from './results-set.js';
@@ -13,19 +14,20 @@ export class ResultsAnalyzer {
1314
const items = new ResultsAnalyzer(currentResult)._collect();
1415

1516
const baseline = baselineResults?.find(
16-
(other) => other.cpuThrottling == currentResult.cpuThrottling &&
17-
other.name == currentResult.name &&
18-
other.networkConditions == currentResult.networkConditions);
17+
(other) => other.cpuThrottling == currentResult.cpuThrottling
18+
&& other.name == currentResult.name
19+
&& other.networkConditions == currentResult.networkConditions
20+
&& JsonStringify(other) != JsonStringify(currentResult));
1921

2022
let otherHash: GitHash | undefined
2123
if (baseline != undefined) {
24+
otherHash = baseline[0];
2225
const baseItems = new ResultsAnalyzer(baseline[1])._collect();
2326
// update items with baseline results
2427
for (const base of baseItems) {
2528
for (const item of items) {
2629
if (item.metric == base.metric) {
2730
item.others = base.values;
28-
otherHash = baseline[0];
2931
}
3032
}
3133
}

packages/replay/metrics/src/results/results-set.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export class ResultsSet {
4949
public items(): ResultSetItem[] {
5050
return this._files().map((file) => {
5151
return new ResultSetItem(path.join(this._directory, file.name));
52-
}).filter((item) => !isNaN(item.number));
52+
}).filter((item) => !isNaN(item.number)).sort((a, b) => a.number - b.number);
5353
}
5454

5555
public async add(newFile: string, onlyIfDifferent: boolean = false): Promise<void> {

packages/replay/metrics/src/util/console.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,13 @@ export function printAnalysis(analysis: Analysis): void {
2626
const table: PrintableTable = {};
2727
for (const item of analysis.items) {
2828
table[AnalyzerItemMetric[item.metric]] = {
29-
value: item.values.diff(0, 1),
29+
value: item.values.value(0),
30+
withSentry: item.values.diff(0, 1),
31+
withReplay: item.values.diff(1, 2),
3032
...((item.others == undefined) ? {} : {
31-
previous: item.others.diff(0, 1)
33+
previous: item.others.value(0),
34+
previousWithSentry: item.others.diff(0, 1),
35+
previousWithReplay: item.others.diff(1, 2)
3236
})
3337
};
3438
}

0 commit comments

Comments
 (0)