Created
May 12, 2022 13:33
-
-
Save AndreiCalazans/81e719432f3a6756b9fc44eceeed22eb to your computer and use it in GitHub Desktop.
Script to run launch Android and retrieve some performance logs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { exec } = require('child_process'); | |
const _exec = async (command) => { | |
return new Promise((res) => { | |
exec(command, (error, stdout) => { | |
if (error !== null) { | |
console.log(`exec error: ${error}`); | |
} | |
res(stdout); | |
}); | |
}); | |
}; | |
const sleep = () => new Promise((res) => setTimeout(res, 10000)); | |
const main = async () => { | |
const clear = 'adb logcat -c'; | |
const stop = 'adb shell am force-stop com.coinbase.android'; | |
const open = 'adb shell monkey -p com.coinbase.android 1'; | |
console.log('clearing logs'); | |
await _exec(clear); | |
for (let i = 0; i < 9; i++) { | |
console.log('run - ', i); | |
await _exec(open); | |
await sleep(); | |
await _exec(stop); | |
} | |
console.log('retrieving logs'); | |
const logs = await _exec('adb logcat -d -s ReactNativeJS'); | |
console.log('Result', logs.match(/mark.*\d\s/g)); | |
return 0; | |
}; | |
main(); |
Author
AndreiCalazans
commented
May 12, 2022
How to get the logs ref
import { PerformanceObserver } from 'react-native-performance';
const measureObserver = new PerformanceObserver((list, observer) => {
list.getEntries().forEach((entry) => {
console.log(`mark - ${entry.name} - ${entry.duration}ms`);
});
});
measureObserver.observe({ type: 'measure', buffered: true });
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment