Android performance detection tool -- traceview

Source: Internet
Author: User

Android performance detection tool -- traceview
1. What should we do if we want to test the code section in the code area marked for testing the gridView setting adapter? It's easy. Use two lines of code to hold it ~ Original code: mPhotoWall. setAdapter (mAdapter); Code marked as test: Debug. startMethodTracing ("my_trace_file"); mPhotoWall. setAdapter (mAdapter); Debug. stopMethodTracing (); this shows that our test starts before setAdapter and ends after it. Here is a file name named my_trace_file. This is the name of the test report after the test. PS: Remember to add the permission: <uses-permission android: name = "android. permission. MOUNT_UNMOUNT_FILESYSTEMS "/> <uses-permission android: name =" android. permission. WRITE_EXTERNAL_STORAGE "/> 2. After viewing the test report running program, we will find our test report file in the sdcard folder. If you want to view the test report file, you can use the command line, move it to drive d adb pull/sdcard/my_trace_file.trace d:/and then call adb pull/sdcard/my_trace_file.trace d:/to open the graphic interface of the test report: iii. Meaning of each parameter in the header nl Cpu Time %: percentage of Time the method is called during running to the total Time. Incl Cpu Time: total execution Time of the method (including the Time consumed to call the sub-function): the Time consumed to call this method * The number of executions. Excl Cpu Time %: percentage of the total Time consumed by the method itself (excluding the Time consumed by calling other methods. Excl Cpu Time: the Time consumed by the method itself. Incl Real Time %: percentage of the actual execution Time of the method to the total Time. Incl Real Time: the Time when the method is actually executed. Excl Real Time %: percentage of the Time when the method is actually executed to the Total Time Excl Real Time: the Time consumed by the method to be actually executed cballs + recurcballs/Total: number of times a method is called + number of repeated calls Cpu Time/Call: the Time when the method is executed. Real Time/Call: the Time when the method is actually executed. PS: generally, add Debug in onCreate () of the activity. startMethodTracing ("Test"), which calls Debug in onStop. stopMethodTracing (). In this way, when we switch to another activity or click the home Key, onStop () will be called, and we can get the complete trace file.

Related Article

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.