IOS mobile phone power consumption test

1. Original test method of power consumption

1.1 Principle of the method:

The power consumption is calculated according to the battery percentage change in the upper right corner of the iPhone.

1.2 Actual operation:

Turn on the battery percentage value display in the iOS general settings, and then operate for 30 minutes, 60 minutes, 90 minutes, and see the difference between the battery percentage value at the beginning and the end.

1.3 Analysis of advantages and disadvantages:

1. The battery percentage data is very rough, and the battery power loss from 90% to 80% is not necessarily equal to 80% power loss to 70%

2. It is necessary to close all background applications of the mobile phone during the test, except the application to be tested, but the statistical power consumption still includes the power consumption of the bright screen and the power consumption of the communication module, so it will be found that the power consumption of the mobile phone with OLED and LCD screens is not high. Same, the power consumption of wifi module and 3G network is different

To sum up: If the power consumption is based on the power consumption of the entire mobile phone, then there are many factors affected and the interference is large, so it is impossible to accurately obtain the real power consumption data of the tested application.

2. Literary test method of power consumption

2.1 Method principle:

Starting from the iOS8 system, the iPhone will see the data of the front and back running time and the battery consumption ratio in the power option (as shown in the figure below), and these data will be automatically collected in the iPhone database and reported to the Apple server, so The data reported by the mobile phone can be intercepted through the HTTP hijacking tool.

picture

2.2 Actual operation:

Step 1: Install the HTTP hijacking tool mitmproxy on the iMac, open the terminal command input interface on the iMac, and enter the following command:

sudo  easy_install  php

sudo  pip  install  mitmproxy

Note: The reason for using mitmproxy is to support the mobile terminal, and there is a Mac version, which is much more convenient than Fiddler and HttpWatch.

Step 2: Place the capture.py script that parses the HTTP request and saves the file on the iMac, then run the command:

mitmdump  -s  “capture.py   --bat”

Step 3: Connect the mobile phone and iMac to the same wifi network, then open the wifi settings in the mobile phone, set the IP of the HTTP proxy server of the mobile phone to the IP of the iMac, and the port to 8080 (as shown in the figure below)

picture

现在我也找了很多测试的朋友,做了一个分享技术的交流群,共享了很多我们收集的技术文档和视频教程。
如果你不想再体验自学时找不到资源,没人解答问题,坚持几天便放弃的感受
可以加入我们一起交流。而且还有很多在自动化,性能,安全,测试开发等等方面有一定建树的技术大牛
分享他们的经验,还会分享很多直播讲座和技术沙龙
可以免费学习!划重点!开源的!!!
qq群号:110685036

 

Step 4: Open Safari on the iPhone, enter http://mitm.it, select the Apple icon and install the mitm certificate. The certificate only needs to be installed for the first test.

picture

Step 5: Go back to the Safari browser, enter diags:// to enter the iOS diagnostic information interface, enter the report number: 123456, click the extended test (as shown in Figure 1), and wait until "Complete" appears in the upper left corner of the interface, A compressed file of power-YYYYMMDD-hhmmss.tar.gz will appear in the same directory of capture.py (as shown in Figure 2).

picture

figure 1

picture

figure 2

Step 6: Double-click the file starting with ID, and the file ending with PLSQL will appear, which can be opened by MesaSQLite, switch to the "SQL Query" option page, and enter the SQL statement.

picture

The record in the red box above shows that: on October 23, 2015, the com.qq.tencent.dailybuild process consumed 436.9832mW/h of electricity within 3600 seconds from 8:00 to 9:00.

View the SQL statement running in the background:

select datetime(timestamp, unixepoch','localtime') AS Time,* from PLAppTimeService_Aggregate_AppRunTime where BundleID= 'com.tencent.qq.dailybuild';

Check the SQL statement of power consumption:

select datetime(timestamp,'unixepoch','localtime') as time, * from PLBLMAccountingService_Aggregate_BLMAppEnergyBreakdown  where  BLMAppName='com.tencent.qq.dailybuild';

View the SQL statement of the temperature:

select datetime(timestamp,'unixepoch','localtime') as time, * from PLBatteryAgent_EventBackward_Battery;

2.3 Analysis of advantages and disadvantages:

advantage:

1) The data obtained by this method is the statistical data of the iOS system, so the data is quite convincing;

2) It is possible to obtain the power consumption data of the application, instead of counting the power consumption of the whole machine.

Disadvantages: The shortest can only count the power consumption data within 1 hour. For the power consumption of the operation with a faster response time, it is recommended to use powermonitor to test.

3. Frequently Asked Questions

Question: What should I do if the command not found prompt appears when running capture.py in mitmdump?

picture

Answer: If the mitmdump command cannot be found, it means that there is a problem with the installation of mitmproxy. You need to run sudo pip install mitmproxy to re-install mitmproxy.

Question: When installing mitmproxy, a libxml/xmlversion.h file not found prompt appears, how to solve it?

picture

Answer: This is an error when installing the dependency package lxml, first execute the command in the red box below according to the warning, and then execute the xcode-select --install command

picture

Question: Why can't I see the mitm certificate installation interface when I enter http://mitm.it in the mobile phone's QQ browser or UC browser ?

Answer: The address must be entered in the Safari browser of the iPhone, and diags:// must also be entered in the Safari browser for the same reason.

The following are supporting learning materials. For friends who do [software testing], it should be the most comprehensive and complete preparation warehouse. This warehouse also accompanied me through the most difficult journey. I hope it can help you too!

Software testing interview applet

The software test question bank maxed out by millions of people! ! ! Who is who knows! ! ! The most comprehensive quiz mini program on the whole network, you can use your mobile phone to do the quizzes, on the subway or on the bus, roll it up!

The following interview question sections are covered:

1. Basic theory of software testing, 2. web, app, interface function testing, 3. network, 4. database, 5. linux

6. web, app, interface automation, 7. performance testing, 8. programming basics, 9. hr interview questions, 10. open test questions, 11. security testing, 12. computer basics

Information acquisition method:

Guess you like

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