I am working on a iOS automation stuff. I am trying to capture the ios performance metrics like CPU usage while my automation script is running. I got below code to do this:
HashMap<String, Object> args = new HashMap<>(); args.put("timeout", 60000); args.put("pid", "current"); args.put("profileName", "Time Profiler"); driver.executeScript("mobile: startPerfRecord", args); // Did some actions on the device args = new HashMap<>(); args.put("profileName", "Time Profiler"); String b64Zip = (String)driver.executeScript("mobile: stopPerfRecord", args); byte bytesZip = Base64.getMimeDecoder().decode(b64Zip); File traceZip = new File("/path/to/trace.zip"); FileOutputStream stream = new FileOutputStream(traceZip); stream.write(bytesZip);
Now, I am getting a .trace file generated at the given path once I execute the above code. I am able to open that .trace file using Instruments tool of xCode. The .trace file has the CPU usage data over the period of time . I want to use that data and draw my graph.
How can I parse that .trace file to extract the CPU usage data.