Skip to content

Commit 21e2192

Browse files
committed
fix(report): ensure ui matches target frame rate
1 parent 75609d9 commit 21e2192

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

packages/core/web-reporter-ui/ReporterView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ const Report = ({
7373
<>
7474
<HideSectionIfUndefinedValueFound>
7575
<div className="mx-8 p-6 bg-dark-charcoal border border-gray-800 rounded-lg">
76-
<FPSReport results={averagedResults} />
76+
<FPSReport reports={reports} />
7777
</div>
7878
<div className="h-10" />
7979
</HideSectionIfUndefinedValueFound>

packages/core/web-reporter-ui/src/sections/FPSReport.tsx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
1-
import React from "react";
2-
import { AveragedTestCaseResult } from "@perf-profiler/types";
1+
import React, { useMemo } from "react";
2+
import { Report as ReportModel } from "@perf-profiler/reporter";
33
import { buildValueGraph } from "./hideSectionForEmptyValue";
44
import { ReportChart } from "../components/Charts/ReportChart";
55

6-
const fpsAnnotationInterval = [{ y: 57, y2: 60, color: "#158000", label: "Safe Zone" }];
7-
8-
export const FPSReport = ({ results }: { results: AveragedTestCaseResult[] }) => {
6+
export const FPSReport = ({ reports }: { reports: ReportModel[] }) => {
97
const fps = buildValueGraph({
10-
results,
8+
results: reports.map((report) => report.getAveragedResult()),
119
stat: "fps",
1210
});
1311

12+
const fpsAnnotationInterval = useMemo(() => {
13+
const targetFps = reports[0].getRefreshRate();
14+
15+
return [
16+
{ y: Math.floor(0.95 * targetFps), y2: targetFps, color: "#158000", label: "Safe Zone" },
17+
];
18+
}, [reports]);
19+
1420
return (
1521
<ReportChart
1622
title="Frame rate (FPS)"

0 commit comments

Comments
 (0)