From c88496e3de04bb54f1502846c42dace946a284d2 Mon Sep 17 00:00:00 2001 From: almouro Date: Mon, 13 May 2024 10:44:41 +0200 Subject: [PATCH] wip --- packages/commands/test/src/PerformanceMeasurer.ts | 10 +++++----- packages/platforms/ios-instruments/README.md | 6 ++---- packages/platforms/ios-instruments/src/index.ts | 4 ++-- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/packages/commands/test/src/PerformanceMeasurer.ts b/packages/commands/test/src/PerformanceMeasurer.ts index d3184049..4f2c6121 100644 --- a/packages/commands/test/src/PerformanceMeasurer.ts +++ b/packages/commands/test/src/PerformanceMeasurer.ts @@ -55,8 +55,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): Promise { @@ -77,10 +80,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(); await this.maybeStopRecording(); diff --git a/packages/platforms/ios-instruments/README.md b/packages/platforms/ios-instruments/README.md index 42e169c2..1bb5f85c 100644 --- a/packages/platforms/ios-instruments/README.md +++ b/packages/platforms/ios-instruments/README.md @@ -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 --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 --testCommand "maestro test test.yaml" --resultsFilePath "./result.json"` - Check the results in the web-reporter `yarn workspace @perf-profiler/web-reporter build` diff --git a/packages/platforms/ios-instruments/src/index.ts b/packages/platforms/ios-instruments/src/index.ts index f254cddd..27aa9af0 100644 --- a/packages/platforms/ios-instruments/src/index.ts +++ b/packages/platforms/ios-instruments/src/index.ts @@ -15,7 +15,7 @@ const startRecord = async ( ): Promise => { 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((resolve) => { recordingProcess.stdout?.on("data", (data) => { @@ -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; };