Skip to content

fix: fix fps safe zone with higher frame rates #345

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Average CPU usage
An app might run at high frame rates, such as 60 FPS or higher, but might be using too much processing power, so it's important to check CPU usage.
Depending on the device, this value can go up to
100% x number of cores
. For instance, a Samsung A10s has 4 cores, so the max value would be 400%.
. For instance, a Samsung A10s has 8 cores, so the max value would be 800%.
High CPU Usage
0.5 s
Impacted threads:
Expand Down Expand Up @@ -862,7 +862,7 @@ exports[`flashlight measure interactive it displays measures: Web app with measu
<code>
100% x number of cores
</code>
. For instance, a Samsung A10s has 4 cores, so the max value would be 400%.
. For instance, a Samsung A10s has 8 cores, so the max value would be 800%.
</div>
</div>
</div>
Expand Down Expand Up @@ -3825,7 +3825,7 @@ Average CPU usage
An app might run at high frame rates, such as 60 FPS or higher, but might be using too much processing power, so it's important to check CPU usage.
Depending on the device, this value can go up to
100% x number of cores
. For instance, a Samsung A10s has 4 cores, so the max value would be 400%.
. For instance, a Samsung A10s has 8 cores, so the max value would be 800%.
High CPU Usage
-
Impacted threads:
Expand Down Expand Up @@ -4226,7 +4226,7 @@ exports[`flashlight measure interactive it displays measures: Web app with no me
<code>
100% x number of cores
</code>
. For instance, a Samsung A10s has 4 cores, so the max value would be 400%.
. For instance, a Samsung A10s has 8 cores, so the max value would be 800%.
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jest.mock("@perf-profiler/profiler", () => {
mockPerformancePolling.setCallback(onMeasure);
onStartMeasuring();
});
mockedProfiler.detectDeviceRefreshRate = jest.fn(() => 120);

return {
...jest.requireActual("@perf-profiler/profiler"),
Expand Down Expand Up @@ -90,6 +91,9 @@ describe("measurePerformance", () => {
],
"name": "TITLE",
"score": 3,
"specs": {
"refreshRate": 120,
},
"status": "SUCCESS",
}
`);
Expand Down
1 change: 1 addition & 0 deletions packages/commands/test/src/__tests__/writeResults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ jest.mock("@perf-profiler/profiler", () => ({
profiler: {
...jest.requireActual("@perf-profiler/profiler").profiler,
installProfilerOnDevice: jest.fn(),
detectDeviceRefreshRate: jest.fn(() => 120),
},
}));

Expand Down
4 changes: 4 additions & 0 deletions packages/commands/test/src/writeReport.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Logger } from "@perf-profiler/logger";
import { profiler } from "@perf-profiler/profiler";
import { averageTestCaseResult } from "@perf-profiler/reporter";
import {
AveragedTestCaseResult,
Expand Down Expand Up @@ -26,6 +27,9 @@ export const writeReport = (
measures.length === 0 || measures[measures.length - 1].status === "FAILURE"
? "FAILURE"
: "SUCCESS",
specs: {
refreshRate: profiler.detectDeviceRefreshRate(),
},
};

/**
Expand Down
4 changes: 2 additions & 2 deletions packages/core/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export interface TestCaseResult {
status: TestCaseResultStatus;
iterations: TestCaseIterationResult[];
type?: TestCaseResultType;
specs?: DeviceSpecs;
specs: DeviceSpecs | undefined;
}

export interface AveragedTestCaseResult {
Expand All @@ -50,7 +50,7 @@ export interface AveragedTestCaseResult {
average: TestCaseIterationResult;
averageHighCpuUsage: { [processName: string]: number };
type?: TestCaseResultType;
specs?: DeviceSpecs;
specs: DeviceSpecs | undefined;
}

// Shouldn't really be here but @perf-profiler/types is imported by everyone and doesn't contain any logic
Expand Down
4 changes: 3 additions & 1 deletion packages/core/web-reporter-ui/ReporterView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const Report = ({
<>
<HideSectionIfUndefinedValueFound>
<div className="mx-8 p-6 bg-dark-charcoal border border-gray-800 rounded-lg">
<FPSReport results={averagedResults} />
<FPSReport reports={selectedReports} />
</div>
<div className="h-10" />
</HideSectionIfUndefinedValueFound>
Expand Down Expand Up @@ -129,6 +129,8 @@ export const ReporterView = ({ measures }: { measures: Measure[] }) => (
status: "SUCCESS",
},
],
// TODO: set specs properly here
specs: undefined,
},
]}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Average CPU usage
An app might run at high frame rates, such as 60 FPS or higher, but might be using too much processing power, so it's important to check CPU usage.
Depending on the device, this value can go up to
100% x number of cores
. For instance, a Samsung A10s has 4 cores, so the max value would be 400%.
. For instance, a Samsung A10s has 8 cores, so the max value would be 800%.
Min Max Range:

41
Expand Down Expand Up @@ -242,7 +242,7 @@ Average CPU usage
An app might run at high frame rates, such as 60 FPS or higher, but might be using too much processing power, so it's important to check CPU usage.
Depending on the device, this value can go up to
100% x number of cores
. For instance, a Samsung A10s has 4 cores, so the max value would be 400%.
. For instance, a Samsung A10s has 8 cores, so the max value would be 800%.
Min Max Range:

21
Expand Down Expand Up @@ -2221,7 +2221,7 @@ exports[`<ReporterView /> renders the comparison view 2`] = `
<code>
100% x number of cores
</code>
. For instance, a Samsung A10s has 4 cores, so the max value would be 400%.
. For instance, a Samsung A10s has 8 cores, so the max value would be 800%.
</div>
<div
class="h-2"
Expand Down Expand Up @@ -2897,7 +2897,7 @@ exports[`<ReporterView /> renders the comparison view 2`] = `
<code>
100% x number of cores
</code>
. For instance, a Samsung A10s has 4 cores, so the max value would be 400%.
. For instance, a Samsung A10s has 8 cores, so the max value would be 800%.
</div>
<div
class="h-2"
Expand Down Expand Up @@ -14031,7 +14031,7 @@ Average CPU usage
An app might run at high frame rates, such as 60 FPS or higher, but might be using too much processing power, so it's important to check CPU usage.
Depending on the device, this value can go up to
100% x number of cores
. For instance, a Samsung A10s has 4 cores, so the max value would be 400%.
. For instance, a Samsung A10s has 8 cores, so the max value would be 800%.
High CPU Usage
3.5 s
Impacted threads:
Expand Down Expand Up @@ -14072,7 +14072,7 @@ Average CPU usage
An app might run at high frame rates, such as 60 FPS or higher, but might be using too much processing power, so it's important to check CPU usage.
Depending on the device, this value can go up to
100% x number of cores
. For instance, a Samsung A10s has 4 cores, so the max value would be 400%.
. For instance, a Samsung A10s has 8 cores, so the max value would be 800%.
High CPU Usage
1 s
(-71%)
Expand Down Expand Up @@ -15591,7 +15591,7 @@ exports[`<ReporterView /> renders the comparison view 4`] = `
<code>
100% x number of cores
</code>
. For instance, a Samsung A10s has 4 cores, so the max value would be 400%.
. For instance, a Samsung A10s has 8 cores, so the max value would be 800%.
</div>
</div>
</div>
Expand Down Expand Up @@ -16024,7 +16024,7 @@ exports[`<ReporterView /> renders the comparison view 4`] = `
<code>
100% x number of cores
</code>
. For instance, a Samsung A10s has 4 cores, so the max value would be 400%.
. For instance, a Samsung A10s has 8 cores, so the max value would be 800%.
</div>
</div>
</div>
Expand Down Expand Up @@ -22040,7 +22040,7 @@ Average CPU usage
An app might run at high frame rates, such as 60 FPS or higher, but might be using too much processing power, so it's important to check CPU usage.
Depending on the device, this value can go up to
100% x number of cores
. For instance, a Samsung A10s has 4 cores, so the max value would be 400%.
. For instance, a Samsung A10s has 8 cores, so the max value would be 800%.
Min Max Range:

70
Expand Down Expand Up @@ -22248,7 +22248,7 @@ Average CPU usage
An app might run at high frame rates, such as 60 FPS or higher, but might be using too much processing power, so it's important to check CPU usage.
Depending on the device, this value can go up to
100% x number of cores
. For instance, a Samsung A10s has 4 cores, so the max value would be 400%.
. For instance, a Samsung A10s has 8 cores, so the max value would be 800%.
Min Max Range:

82
Expand Down Expand Up @@ -23830,7 +23830,7 @@ exports[`<ReporterView /> renders the comparison view with videos 2`] = `
<code>
100% x number of cores
</code>
. For instance, a Samsung A10s has 4 cores, so the max value would be 400%.
. For instance, a Samsung A10s has 8 cores, so the max value would be 800%.
</div>
<div
class="h-2"
Expand Down Expand Up @@ -24549,7 +24549,7 @@ exports[`<ReporterView /> renders the comparison view with videos 2`] = `
<code>
100% x number of cores
</code>
. For instance, a Samsung A10s has 4 cores, so the max value would be 400%.
. For instance, a Samsung A10s has 8 cores, so the max value would be 800%.
</div>
<div
class="h-2"
Expand Down
18 changes: 12 additions & 6 deletions packages/core/web-reporter-ui/src/sections/FPSReport.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
import React from "react";
import { AveragedTestCaseResult } from "@perf-profiler/types";
import React, { useMemo } from "react";
import { Report as ReportModel } from "@perf-profiler/reporter";
import { buildValueGraph } from "./hideSectionForEmptyValue";
import { ReportChart } from "../components/Charts/ReportChart";

const fpsAnnotationInterval = [{ y: 57, y2: 60, color: "#158000", label: "Safe Zone" }];

export const FPSReport = ({ results }: { results: AveragedTestCaseResult[] }) => {
export const FPSReport = ({ reports }: { reports: ReportModel[] }) => {
const fps = buildValueGraph({
results,
results: reports.map((report) => report.getAveragedResult()),
stat: "fps",
});

const fpsAnnotationInterval = useMemo(() => {
const targetFps = reports[0].getRefreshRate();

return [
{ y: Math.floor(0.95 * targetFps), y2: targetFps, color: "#158000", label: "Safe Zone" },
];
}, [reports]);

return (
<ReportChart
title="Frame rate (FPS)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const AverageCPUUsageExplanation = () => (
An app might run at high frame rates, such as 60 FPS or higher, but might be using too much
processing power, so it&apos;s important to check CPU usage.
<br /> Depending on the device, this value can go up to <code>100% x number of cores</code>. For
instance, a Samsung A10s has 4 cores, so the max value would be 400%.
instance, a Samsung A10s has 8 cores, so the max value would be 800%.
</>
);

Expand Down
3 changes: 3 additions & 0 deletions packages/platforms/ios-instruments/src/writeReport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ export const writeReport = (inputFileName: string, outputFileName: string) => {
status: "SUCCESS",
iterations,
type: "IOS_EXPERIMENTAL",
specs: {
refreshRate: FAKE_FPS,
},
};

fs.writeFileSync(outputFileName, JSON.stringify(results, null, 2));
Expand Down
6 changes: 3 additions & 3 deletions website/static/examples/flashlist/report.js

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4620,9 +4620,9 @@ camelcase@^6.2.0:
integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==

caniuse-lite@^1.0.30001587, caniuse-lite@^1.0.30001646, caniuse-lite@^1.0.30001663:
version "1.0.30001666"
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001666.tgz"
integrity sha512-gD14ICmoV5ZZM1OdzPWmpx+q4GyefaK06zi8hmfHV5xe4/2nOQX3+Dw5o+fSqOws2xVwL9j+anOPFwHzdEdV4g==
version "1.0.30001723"
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001723.tgz"
integrity sha512-1R/elMjtehrFejxwmexeXAtae5UO9iSyFn6G/I806CYC/BLyyBk1EPhrKBkWhy6wM6Xnm47dSJQec+tLJ39WHw==

[email protected]:
version "4.1.0"
Expand Down Expand Up @@ -5967,6 +5967,7 @@ eslint-module-utils@^2.12.0:

"eslint-plugin-custom-rules@link:./packages/eslint-plugin-flashlight-eslint-rules/dist":
version "0.0.0"
uid ""

eslint-plugin-import@^2.26.0:
version "2.31.0"
Expand Down