Skip to content

Commit

Permalink
feat: JS and UI thread metrics added
Browse files Browse the repository at this point in the history
  • Loading branch information
kirillzyusko committed Jun 24, 2024
1 parent f178843 commit eeaa464
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
10 changes: 10 additions & 0 deletions tests/e2e/testRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,16 @@ const runTests = async (): Promise<void> => {
branch,
duration: metrics.ram,
});
attachTestResult({
name: `${test.name} (CPU/JS)`,
branch,
duration: metrics.jsThread,
});
attachTestResult({
name: `${test.name} (CPU/UI)`,
branch,
duration: metrics.uiThread,
});
}
removeListener();
resolve();
Expand Down
9 changes: 8 additions & 1 deletion tests/e2e/utils/measure.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {profiler} from '@perf-profiler/profiler';
import {getAverageCpuUsage, getAverageFPSUsage, getAverageRAMUsage} from '@perf-profiler/reporter';
import {getAverageCpuUsage, getAverageCpuUsagePerProcess, getAverageFPSUsage, getAverageRAMUsage} from '@perf-profiler/reporter';
import {ThreadNames} from '@perf-profiler/types';
import type {Measure} from '@perf-profiler/types';

let measures: Measure[] = [];
Expand All @@ -23,11 +24,17 @@ const start = (bundleId: string) => {
const stop = () => {
polling.stop();

const average = getAverageCpuUsagePerProcess(measures);
const uiThread = average.find(({processName}) => processName === ThreadNames.ANDROID.UI)?.cpuUsage;
// most likely this line needs to be updated when we migrate to RN 0.74 with bridgeless mode
const jsThread = average.find(({processName}) => processName === ThreadNames.RN.JS_ANDROID)?.cpuUsage;
const cpu = getAverageCpuUsage(measures);
const fps = getAverageFPSUsage(measures);
const ram = getAverageRAMUsage(measures);

return {
uiThread,
jsThread,
cpu,
fps,
ram,
Expand Down

0 comments on commit eeaa464

Please sign in to comment.