Trace tool for iOS/macOS
AppleTrace is developed for analyzing app's performance on iOS/macOS.
- User-defined trace section.
- [arm64 only] Trace all Objective C methods.
- Produce trace data.
- Copy from app's sandbox directory.
- Merge (all) trace data files into one file
trace.json. (There may be more than 1 trace file.) - Generate
trace.htmlbased ontrace.json.
See below for more detail.
Until now , there are 2 ways for generating trace data.
-
Manual set section.
Call
APTBeginSectionat the beginning of method ,andAPTEndSectionat the end of method. For Objective C method (whether instance method or class method), there areAPTBeginandAPTEndmacro for easy coding.void anyKindsOfMethod{ APTBeginSection("process"); // some code APTEndSection("process"); } - (void)anyObjectiveCMethod{ APTBegin; // some code APTEnd; }Sample app is
sample/ManualSectionDemo. -
Dynamic library hooking all objc_msgSend.
Hooking all objc_msgSend methods (based on HookZz). This only support arm64.
Sample app is
sample/TraceAllMsgDemo.
Using any kinds of method, copy <app's sandbox>/tmp/appletracedata out of Simulator/RealDevice.
Merge/Preprocess the appletracedata.
python merge.py -d <appletracedata directory> This will produce trace.json in appletracedata directory.
Generate trace.html using catapult.
python catapult/tracing/bin/trace2html appletracedata/trace.json --output=appletracedata/trace.html open trace.html Open sampledata/trace.html.
- dtrace as data source.

