guldan is an open source time-consuming analysis tool for iOS Objective-C method. It can facilitate development/testing students to quickly obtain the cost time of all OC methods within a certain period of time when the APP is running, and supports visualization. see more: juejin paper
scheme compare | advantage | shortcomint |
---|---|---|
static instrumentation | The entry edge and exit edge of the function can be overwritten, and the entire execution process of the function can be covered | Negative impact on package volume; cannot be applied to closed source libraries; high access cost |
Messier | Analysis product visualization, with time series | Relying on third-party maintenance, some iOS systems cannot be applied |
Xcode Instruments | Powerful functions and support for sub-thread analysis | High cost of use; unsustainable analysis results; does not support timing |
our scheme | Low invasiveness, high performance, low cost of use, visualization | Does not support simulators, only for OC methods time-consuming |
(1) Install via CocoaPods command
pod 'Guldan'
(2) import header file
#import <Guldan/GDNOCMethodTimeProfiler.h>
(3)start analysis
[GDNOCMethodTimeProfiler start];
(4)stop analysis
[GDNOCMethodTimeProfiler stop];
(5)output result path
[GDNOCMethodTimeProfiler handleRecordsWithComplete:^(NSArray<NSString *> * _Nonnull filePaths) {
// file path
}];
(6)output file path It can be opened quickly with the help of some sandbox tools. The sandbox directory can also be downloaded using Xcode. Here is only how to use Xcode to find the result file in the sandbox. Xcode window/Devices and Simulators/select target APP/Click the gear icon and select「Download Container」
Right-click the file downloaded in the previous step, select "Show Package Contents" and find the oc_method_cost_mainthread file
(7)Desktop visualization with Chrome Enter chrome://tracing/ in the chrome browser and drag in the oc_method_cost_mainthread file。
HUOLALA mobile technology team
Guldan is released under the Apache 2.0 license. See LICENSE for details.