The App power analysis test you want is here

Batterystats is a tool included in the Android framework to collect battery data on a device. You can use adb to dump the collected battery data to your development computer and create a report that can be analyzed using Battery Historian. Battery Historian converts reports from Batterystats into HTML visualizations that can be viewed in a browser.

Suitable scene:

  • Shows where and how processes are consuming battery power.

  • Identify which tasks in your app the system might delay or even remove in order to improve battery life.

01. Install Battery Historian

The easiest way to install Battery Historian is to use Docker. For other installation methods (including compiling from source), see the README on the project's GitHub page.

To install using Docker:

  • Follow the instructions on the Docker website to install Docker Community Edition.

  • To confirm that Docker is installed correctly, open a command line and enter the following command:

docker run hello-world

  • Run the Battery Historian image with

docker run -p port_number:9999 gcr.io/android-battery-historian/stable:3.0 --port 9999

Battery Historian will use the port of your choice, as specified with port_number.

  • Go to Battery Historian in your browser to confirm it's working.

The exact address varies by operating system:

for Linux and Mac

The Battery Historian can be found under http://localhost:port_number.

for Windows

After starting Docker, it will tell you the IP address of the computer it is using. So, for example, if the IP address is 123.456.78.90, the Battery Historian can be found under http://123.456.78.90:port_number

You will see the Battery Historian start page, from which you can upload and view battery statistics.

02. Use Batterystats to collect data

To use Batterystats to collect data from your devices and open that data in Battery Historian :

Mobile device connected to computer.

In a terminal window, close the running adb server.

adb kill-server

Restart adb and check for connected devices.

adb devices

Your device should be listed, if you don't see any, make sure your phone is connected and USB debugging is on, then kill and restart adb

Reset battery data collection

adb shell dumpsys batterystats --reset

The device always collects batterystats and other debug information in the background. A reset operation clears old battery collection data. If it is not reset, the output will be too large.

Disconnect the device from the computer so that only the device battery is drained. Use your app and do what you want to do with the data; for example, disconnect from Wi-Fi and send the data to the cloud. Reconnect the phone. Make sure your phone is recognized

Dump all battery data. This process may take a while:

adb shell dumpsys batterystats > [path/]batterystats.txt

A batterystats.txt file is created in the directory you specify using the optional path parameter. If you don't specify a path, the file will be created in your home directory.

Create reports using raw data

adb bugreport > [path/]bugreport.zip

Bug reports may take several minutes to complete. Do not disconnect the device or cancel the process until it is complete.
Like batterystats.txt above, these files are created by the system in the directory you specify using the optional path parameter. If you do not specify a path, the files will be created in your home directory.

If Battery Historian is not already running, run it with

docker --run -p port_number:9999 gcr.io/android-battery-historian:2.1 --port 9999

To view data in Battery Historian , open Battery Historian in your browser.

(Battery Historian runs under http://localhost:port_number for Mac and Linux. Battery Historian runs under http://your_IP_address:port_number for Windows.)

Click Browse and select the bug report file you created above

Click Submit. Battery Historian will open the graph you created from the batterystats data.

03. Use the Battery Historian chart to view data

The Battery Historian graph displays power-related events over time .

Each row displays a colored bar segment when a system component is active, indicating that it is draining battery power. The graph does not show the power used by the component, only that the associated app is active. The chart is organized by category and displays a bar for each category over time, as indicated by the x-axis of the chart.

Add additional metrics from the dropdown:

Hover over the info icons to see more information about each metric, including the key corresponding to the color used in the chart

Hover over a bar to see more details about that metric and battery stats at a specific point on the timeline

04. Other Batterystats output

You can view additional information in the batterystats.txt file in the statistics section below the Battery Historian graph

  • The System Stats tab contains system-wide statistics such as battery signal level and screen brightness. This information is fully reflective of the specific condition of the device. This is especially useful to ensure that no external events affect your tests

  • The App Stats tab contains information about a specific app. Sort the list of apps using the 3 Sort apps drop-down list in the App Selection pane on the left. You can select a specific app to view stats using the 4 app dropdown below


Finally: The following complete software testing video learning tutorial has been sorted out and uploaded. Friends can get it for free if they need it [100% free guarantee]

These materials should be the most comprehensive and complete preparation warehouse for [software testing] friends. This warehouse has also accompanied tens of thousands of test engineers through the most difficult journey. I hope it can help you too!

 软件测试技术交流群社:110685036(里面还有工作内推机会,毕竟我们是关系社会。)

Software Testing Interview Documentation

We must study to find a high-paying job. The following interview questions are the latest interview materials from first-tier Internet companies such as Ali, Tencent, and Byte, and some Byte bosses have given authoritative answers. Finish this set The interview materials believe that everyone can find a satisfactory job.



 

How to obtain interview documents:

Guess you like

Origin blog.csdn.net/jiangjunsss/article/details/130128879