background
Performance issues
Under normal circumstances, the performance of the App does not directly cause it to be unusable, but it will potentially affect the user experience. In the current "volume" of many apps, a bad experience can even lead to the loss of users. for example:
• Start-up speed is too slow
• High CPU occupancy rate caused by mobile phone heating, fast power consumption
• Unexplained crash
•…and many more
Prevention and inspection
Of course, as a developer, you must avoid some performance problems when writing code. for example:
• Optimize calculation complexity to reduce CPU usage
• Write unit tests
•...and many more
Of course, making good use of tools can efficiently monitor App performance issues and help developers fix defects in product experience in a timely manner. There are many APM tools on the market, because the author has used U-App in the project to perform application information statistics, here is some experience using U-Meng U-APM.
U-APM use medical examination
integrated
Refer to the integration instructions of the official platform, take iOS as an example, here is a brief description
1. U-APM
, and generate a Appkey
2. It is recommended to use CocoaPods
to access SDK pod 'UMCommon'
3.pod 'UMDevice'
4.pod ‘UMAPM’
In the AppDelegate.m
file, add the following
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[UMConfigure initWithAppkey:@"61276660870a7a610a4f67f5" channel:@""];
// Appkey在步骤1中生成
// channel字段为自定义渠道区分,不填写则被默认为是"App store" return YES;
}
analysis result
1. Crash analysis
I just handwritten a crash bug that can be triggered automatically on the homepage of the project. The analysis results are illustrated as follows:
The graph of the collapse is an overall display for developers. The important thing is that in the error list at the bottom of the page, you can view the number of times a certain error has occurred, the type, and the number of users affected. This is very convenient as a developer can quickly and accurately determine the priority when modifying a bug. In addition, there are separate error detail pages for errors, and most of the bugs can be accurately located.
Later U-APM
startup crash analysis, I started in the project’s startup method
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
That is Appkey
bug was written separately, and the channel name was temporarily used to distinguish it.
The results showed that the Appkey
that occurred before the configuration 06180a2b1684c6 could not be captured.
Some people may ask: Isn't this inevitable? You haven't configured it yet...
This is exactly what I want to talk about. Because in many cases, when we configure some third-party libraries, because the integration method is too simple, we will always add a line of code according to the official tutorial at will, and do not look at the best position it should be in the project code. . Because this does not affect the operation of the project, this kind of detail can easily be overlooked. I hope that at any time, developers should develop the habit of trying to think before each line of code is typed.
2. Caton analysis
Caton’s list and details are the same as crashes, which can be queried and located. And it can mark 4 states (unprocessed, repaired, ignored, repaired).
I also added a stutter warning plan. As long as the number of stuttered users exceeds 5%, I will be notified by email. It successfully triggered an alarm message within an hour and reminded me in the email.
3. Start analysis
I used random numbers to randomly slow down the startup speed of the project. By default, the first start/cold start is more than 3 seconds as slow start, and the hot start is more than 1 second. Here is an example of cold start:
The analysis histogram also shows the proportion of normal start and slow start
4. Memory analysis
In the analysis of OOM, it seems that the support for Android is even better than iOS. Due to the Jetsam mechanism of iOS, only a special crash caused by the program memory exceeding the limit is analyzed here. Including the capture of exceptions is not all detectable.
5. Distribution analysis
The platform can provide distribution status in the analysis of the above four modules (crash, freeze, slow start, OOM abnormality), including device distribution, system distribution, operator distribution, version distribution, page distribution, channel distribution, and geographic distribution.
6. Custom configuration module
U-APM
also provides a collection switch, which needs to be configured in the code before initialization.
The above is all the functions U-APM
There are also some functions that I have no time to experience waiting for more developers to use, such as "cloud real machine", "API upload symbol table page overall loading speed rendering" and so on.
Some suggestions to share
An analysis error occurred in the operator module of Caton Analysis and Crash Analysis. I am using a telecom broadband and telecom card, but the analysis results show that I am using a China Mobile operator. Of course, for this kind of problem, the platform has another customer service ticket that can be raised, and I won't repeat it here. (From the perspective of using other Umeng products in the past, the feedback efficiency of customer service work orders is still quite good)
It is also worth mentioning that because the author has completely transitioned the development language to Swift
in the project, but during the integration, the official reminder that Swift
currently only supports U-App statistics, and other businesses do not Swift
support 06180a2b16866f. I also created an OC project overnight to experience it, and did not try to access it Swift
Now, Swift
has become the mainstream language for iOS development. I hope that U-APM
can fully support 06180a2b168673 in the future to Swift
more convenient for developers.
Of course, this does not prevent it from being able to meet the basic needs of developers for performance monitoring in OC projects:
• integration method is simple and fast
• tracks detailed information about crashes and freezes, and easily locates the root cause
• The analysis diagram is clear and clear, and the multi-state is easy to manage
• identifies the device type (iPhone/iPad/iPod, operating system version, carrier type), and classifies device performance **
Finally, I still hope that the appropriate use of tools can improve development efficiency, but please don't forget to think too much.
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。