Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Almouro committed May 13, 2024
1 parent dc16eb8 commit 4996384
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
10 changes: 5 additions & 5 deletions packages/commands/test/src/PerformanceMeasurer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,11 @@ export class PerformanceMeasurer {
});
}

forceStop() {
async forceStop() {
// Ensure polling has stopped
this.polling?.stop();
// Hack for ios-instruments to get the measures at the end of the test
await profiler.getMeasures();
}

async stop(duration?: number) {
Expand All @@ -61,10 +64,7 @@ export class PerformanceMeasurer {
await new Promise((resolve) => setTimeout(resolve, POLLING_INTERVAL * 2));
}

// Ensure polling has stopped
this.polling?.stop();
// Hack for ios-instruments to get the measures at the end of the test
await profiler.getMeasures();
await this.forceStop();

return {
time: time ?? 0,
Expand Down
6 changes: 2 additions & 4 deletions packages/platforms/ios-instruments/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@ Requirements:

- `maestro` installed
- `node` installed
- `idb` installed

## Steps

- Get a running simulator id with `xcrun simctl list devices`
- Create template Flashlight in Xcode Instruments (with cpu-profile and memory usage)
- Add your own test in `test.yaml`
- `PLATFORM=ios-instruments node packages/commands/test/dist/bin.js test --bundleId <YOUR_APP_ID> --simulatorId 9F852910-03AD-495A-8E16-7356B764284 --testCommand "maestro test test.yaml" --resultsFilePath "./result.json"`
PLATFORM=ios-instruments node packages/commands/test/dist/bin.js test --bundleId <YOUR_APP_ID> --testCommand "maestro test test.yaml" --resultsFilePath "./result.json"`

- Check the results in the web-reporter
`yarn workspace @perf-profiler/web-reporter build`
Expand Down
4 changes: 2 additions & 2 deletions packages/platforms/ios-instruments/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const startRecord = async (
): Promise<ChildProcess> => {
const templateFilePath = `${__dirname}/../Flashlight.tracetemplate`;
const recordingProcess = executeAsync(
`xcrun xctrace record --device ${deviceUdid} --template ${templateFilePath} --attach ${appPid} --output ${traceFile}`
`arch -arm64 xcrun xctrace record --device ${deviceUdid} --template ${templateFilePath} --attach ${appPid} --output ${traceFile}`
);
await new Promise<void>((resolve) => {
recordingProcess.stdout?.on("data", (data) => {
Expand All @@ -30,7 +30,7 @@ const startRecord = async (
const saveTraceFile = (traceFile: string): string => {
const xmlOutputFile = getTmpFilePath("report.xml");
executeCommand(
`xctrace export --input ${traceFile} --xpath '/trace-toc/run[@number="1"]/data/table[@schema="time-profile"]' --output ${xmlOutputFile}`
`arch -arm64 xctrace export --input ${traceFile} --xpath '/trace-toc/run[@number="1"]/data/table[@schema="time-profile"]' --output ${xmlOutputFile}`
);
return xmlOutputFile;
};
Expand Down

0 comments on commit 4996384

Please sign in to comment.