How does the app test test the startup time?

Source: Internet
Author: User
Tags time and seconds

Copyright notice: This article by He Xiaowei original article, reprint please indicate source:
Article original link: https://www.qcloud.com/community/article/687066001482481827

Source: Tengyun https://www.qcloud.com/community

Background introduction

Android users may often encounter the following problems: 1) The application background is open, the mobile phone quickly ran out of electricity-the application of power consumption; 2) first/non-first launch of the application, the application is particularly slow-application startup slow, 3) The application process, more and more card--CPU capacity insufficient/memory leaks; 4) Apply page lag--Low frame rate, page lag. Therefore, for Android applications that are developed, they must be tested for performance, otherwise they will directly affect the user experience.

Android app performance tests typically include: Startup time, Memory, CPU, power consumption, traffic, smoothness, and more. This time first introduces the test method of startup time.

Startup time for app performance testing, startup time is an important indicator, start time is divided into two cases, one is the cold start time (usually the system restarts, that is, before the start of the app process), and the other is hot start, that is, the app from being switched to the foreground (point back to exit and then click the icon to start). During QA testing, the startup time of the cold start is generally concerned. The following is the introduction of three test start-up time for your reference, can be targeted to use.

1.1 Using the ADB command

1.1.1 Test Method Enter adbshell am start -W packagename/MainActivity the command to calculate the start time. Such as:

Figure 1 Application The first launch is what we often call cold start, when the process of your application is not created. This is also a usage scenario for most applications. After you click on your app's icon on the desktop, you first create the process and then start mainactivity. This time Adbshell am start-w packagename/mainactivity returned results, Is the start time of the standard application. Note that the phone before Android 5.0 is not waittime this value. The difference between thistime/totaltime/waittime and the following is its explanation.WaitTime=endTime-startTime

    • StartTime the point in time that the startactivityandwait () was just ready to be called
    • Endtime records the point in time that the startactivityandwait () function call returned
    • WaitTime = startactivityandwait () call time-consuming.

WaitTime is the total time-consuming, including the previous application activity pause and the time when the new app started; Thistime indicates that the start of the last activity for a series of start-up activity is time consuming; TotalTime indicates the time-consuming start of a new application. This includes the start of the new process and the start of the activity, but does not include the time of the previous app activity pause. In other words, developers generally only care about totaltime, this time is the actual start of their own application time-consuming.

To summarize, if you only care about the start time of an application itself, refer to TotalTime, if you are concerned about the time-consuming system startup application, refer to waittime; If you are concerned about application interface activity start time, refer to Thistime.

1.1.2 Summary

This method calculates the time from the time the system starts processing the activity to the time it takes to run the layout and draw functions, and the simple understanding is the time it takes to start the activity, not the time it takes to click icon to receive a message from the system. Obviously, this time does not fully simulate the start time of user operation scenarios. Secondly, the method only calculates the whole start time of an activity, and does not calculate the time of each function separately, it is not easy to locate the problem. For these two questions, let's take a look at how the following two methods are solved.

Our focus in testing is actually the user experience start time, then the above time will not meet our needs. Since it's a user experience, we can use Screenrecord for screen recording and analyze video in a more intuitive way.

1.2 Using Screenrecord for screen recording

1.2.1 test Method (1) Enter the command adb shellscreenrecord--bugreport/sdcard/lanch.mp4--bugreport parameter will make the video output some time information and frame information so that we can analyze the startup time. (2) Click the Collect icon, after the app is fully activated, use CTRL + C to end the video recording. (3) Use the command adb pullsdcard/lanch.mp4./, Export Video (4) to export the video to the computer, use the video software that can be played by frame to open (QuickTime on Mac can be, win can use KMPlayer), and play by frame. As shown: Figure 2 plays the video by frame, the top left corner of the video shows the time of each frame (accurate to MS) and the number of frames. , 11:09:38.031 represents the time and seconds, f=333 is the number of frames. In the video, you will see that the icon is dimmed and then highlighted, when the system starts processing the icon click event. You can use this as the click Time, and then according to the experience requirements, see the app launch page completely painted as the end time, this time minus the click Time is the app startup time.

1.2.2 summarizes the method although it can simulate the user's operation scenario, but the operation cost is high and cannot be accurate and clear to know which function call time is too long. The above two methods, single from the start-up time, is unable to locate the specific function which time is more, when the startup time is greater than the predetermined start time threshold, need to step by step log, analysis to identify the cause. The following method is to paste the current calculation of the start time, you can clearly see the call time of each function.

1.3 Code burying point, view output log

1.3.1 test method in the code, the output log view. Take the bar for example, is the entire start to go through the operation. Figure 3 What to do each step, you can refer to the following table. Figure 4 This lets you test the start-up time with the output log, which makes it easy for QA to see the time spent on each module, such as.

1.3.2 summarizes such a point, it can be clear to see the total time spent on the activity and the various functions of time-consuming situation, so in the test process, if you encounter problems can easily locate the specific function. In the test process also has targeted points, such as post-bar live post will be integrated into the form of plug-ins, testing, you can pay more attention to plugin initialization time.

For the start-up time of this performance indicator, the personal feel that the way of the output log is more ideal, QA in the testing process found that there are suspected problems, can give a specific function time.

How does the app test test the startup time?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.