CN107977318B - Energy consumption and performance test method for Android application program - Google Patents

Energy consumption and performance test method for Android application program Download PDF

Info

Publication number
CN107977318B
CN107977318B CN201711415982.0A CN201711415982A CN107977318B CN 107977318 B CN107977318 B CN 107977318B CN 201711415982 A CN201711415982 A CN 201711415982A CN 107977318 B CN107977318 B CN 107977318B
Authority
CN
China
Prior art keywords
android
application program
virtual machine
tested
power
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201711415982.0A
Other languages
Chinese (zh)
Other versions
CN107977318A (en
Inventor
孙玉霞
夏浩源
尹恺彬
陈雁佳
翁健
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Jinan University
Original Assignee
Jinan University
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Jinan University filed Critical Jinan University
Priority to CN201711415982.0A priority Critical patent/CN107977318B/en
Publication of CN107977318A publication Critical patent/CN107977318A/en
Application granted granted Critical
Publication of CN107977318B publication Critical patent/CN107977318B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The invention discloses an energy consumption and performance testing method of an Android application program, which comprises the steps of integrating plug-ins comprising an energy consumption testing tool PowerTutor, a performance testing tool top, a vmstat and an iostat in an Eclipse integrated development environment; the method comprises the steps of running a plug-in, and installing a PowerTutor into an Android virtual machine or an Android real machine; recording the power consumption of each part by the PowerTutor; meanwhile, CPU occupation, memory occupation and disk reading and writing conditions of the tested Android application program in each time period in the running time are obtained through the adb shell running performance testing tools top, vmstat and iostat.

Description

Energy consumption and performance test method for Android application program
Technical Field
The invention belongs to the technical field of software testing and development, and particularly relates to an energy consumption and performance testing method for an Android application program.
Background
Along with the popularization of smart phones, mobile phones have wider and wider market prospects, and provide more and more convenient functions for users. The importance of the operating system of the mobile device is increasingly highlighted, and the development speed of the Android system is particularly obvious. Recent market research shows that the market share of the Android operating system in the smartphone in the fourth quarter of 2015 exceeds 75%. In addition, with the continuous progress of application development technology, Android application stores are also continuously expanding, and applications with various functions and excellent visual effects are developed in a large number. However, due to the self-limitation of the mobile device, for example, the battery is limited and cannot be charged at any time, the size is small and hardware equivalent to the performance of a PC cannot be borne, and when the mobile phone frequently runs high-quality applications such as this, problems such as reduction of system running smoothness, serious heat generation, too fast electric consumption and insufficient endurance often occur, which leads to the problem that the service quality cannot meet the user requirements and brings down the user experience. On the other hand, under the condition of similar functions, consumers tend to select applications with good performance, less occupied hardware resources such as a CPU and the like and less power consumption. Therefore, how to improve the system and application performance based on the Android os and solve the problem of too fast power consumption is one of the key points attracting users, and has also been paid more and more attention by researchers.
For developers, if the problem and reason of high power consumption can be found and timely adjusted in the development stage, the usability of the application is improved, the utilization rate of the software application can be greatly improved, and the user experience is improved. On the other hand, the performance of the application is also very important for developers, and the performance of the mobile phone application in terms of CPU, memory, etc. should be emphasized more than that of the computer-side program due to the performance limitation of the platform, so as to develop the application with high performance and low energy consumption.
In the current android development process, although there are many performance and electric quantity test systems, system tools are often too dispersed, each tool in the system needs complex configuration and usually runs under a command line, and a performance and electric quantity monitoring system which is intuitive, comprehensive and easy to use synchronously in the development process is lacked. With the rapid rise of smart phones, the current power consumption test and performance test of mobile phones are gradually valued, but still there are many problems worth solving. For example, Hoque et al mention that power consumption needs to be measured by connecting additional hardware to the handset, and that it is still difficult to obtain the power consumption of each component of the handset from the total power consumption. In the paper of gerrardo et al, in the process of discovering malicious applications by performing performance tests on a large number of android applications in the market, different Linux command line tools are still used for obtaining corresponding data for various performance indexes. For a common developer, a plurality of tools need to be used simultaneously, each tool still needs to be configured in a relatively complex manner, so that the test is inconvenient, and the obtained data is obtained in a command line form and is not intuitive.
Disclosure of Invention
The invention aims to overcome the defects of the prior art and provide a method for testing the energy consumption and performance of an Android application program.
The purpose of the invention is realized by the following technical scheme: an energy consumption and performance testing method for an Android application program comprises the following steps:
step S1, integrating plug-ins including a power consumption testing tool PowerTutor, a performance testing tool top, a performance testing tool vmstat and a performance testing tool iostat in an Eclipse integrated development environment;
step S2, running the plug-in an Eclipse integrated development environment, and installing an energy consumption testing tool PowerTutor into an Android virtual machine or an Android real machine by the plug-in;
step S3, when the Android application program to be tested runs in the Android virtual machine or the Android real machine, the power consumption of each component in the Android virtual machine or the Android real machine is respectively recorded by a power consumption tester PowerTutor;
meanwhile, in an Eclipse integrated development environment, a performance testing tool top, a performance testing tool vmstat and a performance testing tool iostat are run through an adb shell, CPU occupation conditions of the Android application program to be tested in each time period in the Android virtual machine or the Android real machine in the running time are recorded through the performance testing tool top, memory occupation conditions of the Android application program to be tested in each time period in the Android virtual machine or the Android real machine in the running time are recorded through the performance testing tool vmstat, and disk reading and writing conditions of the Android application program to be tested in each time period in the Android virtual machine or the Android real machine in the running time are recorded through the performance testing tool iostat.
Preferably, in the step S3, when the Android application program to be tested runs in the Android virtual machine or the Android real machine, the energy consumption testing tool PowerTutor records the power consumption of the CPU, the display screen, the Wi-Fi module and the 3G network in the Android virtual machine or the Android real machine, respectively.
Preferably, in step S3, when the tested Android application program runs in the Android virtual machine or the Android real machine, the energy consumption testing tool PowerTutor first obtains the power consumption of the CPU in the Android virtual machine or the Android real machine, and then obtains the power consumption of the CPU in the Android virtual machine or the Android real machine running the tested Android application program, and the specific process is as follows:
step S31, firstly, determining the model of the Android virtual machine or the Android real machine where the detected Android application program is located, acquiring a direct relation curve of the frequency and the power of a CPU (Central processing Unit) of Android of the model built in a power consumption testing tool PowerTutor, and obtaining the real-time power consumption of the CPU of the Android virtual machine or the Android real machine where the detected Android application program is located according to the real-time frequency of the Android virtual machine or the Android real machine where the detected Android application program is located through the acquired CPU frequency and power curve;
the relation curve diagram between the frequency and the power of Android terminals of various models is built in the energy consumption testing tool PowerTutor;
step S32, when the power consumption of the CPU in the Android virtual machine or the Android real machine in a certain period of time for running the Android application program to be detected is calculated, accumulating the real-time power consumption of the Android virtual machine or the Android real machine in which the Android application program to be detected is located in the time period to obtain the CPU power consumption of the Android virtual machine or the Android real machine in which the Android application program to be detected is located in the time period
Figure BDA0001522005440000031
Step S33, obtaining the CPU utilization rate util of the tested Android application program when running in the Android virtual machine or the Android real machine, and obtaining the CPU power consumption of the Android virtual machine or the Android real machine of the tested Android application program in the period of time obtained in the step S32
Figure BDA0001522005440000032
Multiplying the CPU utilization rate util of the tested Android application program when the tested Android application program runs in the Android virtual machine or the Android real machine to obtain the CPU Power consumption Power of the tested Android application program when the CPU runs in the Android virtual machine or the Android real machine in the period of timeCPU
Figure BDA0001522005440000033
In step S3, the specific process that the energy consumption testing tool PowerTutor records the power consumption of the WIFI module in the Android virtual machine or the Android real machine is as follows:
step S311, when the tested Android application program runs, acquiring time proportion occupied by four states of the WIFI module per second, wherein the four states refer to a high-power state, a low-power state, a high-power data transmission state and a low-power data transmission data state of the WIFI module;
step S312, correspondingly multiplying the power of the WIFI module in each state in each second operation time by the time proportion occupied by each state in each second, and adding to obtain the real-time power consumption E per second of the WIFI module in the Android virtual machine or the Android real machine:
E=A×a+B×b+C×c+D×d;
a, B, C and D are powers in the WIFI module high power state, low power state, high power data transmission state, and low power data transmission data state, respectively; a. b, c and d are respectively time proportions respectively occupied by the WIFI module in a high-power state, a low-power state, a high-power data transmission state and a low-power data transmission data state every second; wherein
The power A of the WIFI module in the high-power state is as follows:
A=[710mW+βcr(Rchannel)×Rdata];
βcr(Rchannel)=48-0.768×Rchannel
wherein R ischannelFor WIFI Module uplink channel Rate, RdataThe data rate is the WIFI module uplink data rate;
the power B of the WIFI module in the low-power state, the power C of the WIFI module in the high-power data transmission state and the power D of the WIFI module in the low-power data transmission data state are fixed values.
Further, the step S3 includes the following steps of calculating power consumption of a certain method in the Android virtual machine or the Android real machine in a certain period of time when the CPU runs the tested Android application program, where the specific process is as follows: firstly, the utilization rate of a CPU (Central processing Unit) of a tested Android application program in the running process of an Android virtual machine or an Android real machine is obtained, then the power consumption of the CPU of the Android virtual machine or the Android real machine in the period of time for running the tested Android application program is multiplied by the utilization rate of the CPU of the tested Android application program in the running process of the method of the Android virtual machine or the Android real machine, and the power consumption of a certain method in the Android application program running of the CPU of the Android virtual machine or the Android real machine in the period of time is obtained.
Preferably, in step S1, the plug-in integrated into the Eclipse integrated development environment further includes a performance measurement tool procrank, when the Android application to be tested runs in the Android virtual machine or the Android real machine, the performance measurement tool procrank is run in the Eclipse integrated development environment through the adb shell, and the memory occupation situation of each process of each time period in the Android virtual machine or the Android real machine during the running time of the Android application to be tested is recorded through the performance measurement tool procrank.
Preferably, the method further comprises the following steps: configuring a package name and a working space path of the tested Android application program in a configuration file; and finding the detected Android application program in an Android virtual machine or an Android real machine through the configured package name and the working space path of the detected Android application program in an Eclipse integrated development environment.
Preferably, in the step S3, after the power consumption of each component in the Android virtual machine or the Android real machine is recorded by the power consumption testing tool PowerTutor, power and time curve graphs of each component are respectively generated and visualized through an open source drawing type SWT-Chart in the Eclipse integrated development environment.
Preferably, in the step S3, visualizing, in the running time, CPU occupation situation information of each time period in the Android virtual machine or the Android real machine of the tested Android application recorded by the performance testing tool top, in an Eclipse integrated development environment;
visualizing the memory occupation condition information of the tested Android application program recorded by the performance testing tool vmstat in the Android virtual machine or the Android real machine in each time period in the running time in an Eclipse integrated development environment;
and visualizing the disk read-write condition information of the tested Android application program recorded by the performance testing tool iostat in each time period in the Android virtual machine or the Android real machine in the Eclipse integrated development environment in the running time.
Preferably, in step S1, the plug-in integrated into the Eclipse integrated development environment further includes a coverage rate tool Emma;
in step S3, when the Android virtual machine or the Android real machine runs the Android application program to be tested, the coverage rate tool Emma collects coverage rate information of the Android application program to be tested in the test process by inserting the Java bytecode file compiled in the Android application program to be tested.
Furthermore, after the coverage rate information of the detected Android application program is collected by the coverage rate tool Emma, the coverage rate information is visually displayed on a code line of an editor in the Eclipse integrated development environment through the expansion of a tool Marker and a tool Annotation in the Eclipse integrated development environment, and the power consumption information and the corresponding code line of each method of the detected Android application program running in an Android virtual machine or an Android real machine are displayed on a tool Marker panel.
Compared with the prior art, the invention has the following advantages and effects:
(1) the invention relates to an energy consumption and performance testing method of an Android application program, which comprises the steps of integrating plug-ins comprising an energy consumption testing tool PowerTutor, a performance testing tool top, a performance testing tool vmstat and a performance testing tool iostat in an Eclipse integrated development environment; then, the plug-in is operated in an Eclipse integrated development environment, and an energy consumption testing tool PowerTutor is installed in an Android virtual machine or an Android real machine; when the Android application program to be tested runs in the Android virtual machine or the Android real machine, the power consumption of each component in the Android virtual machine or the Android real machine is respectively recorded by a power consumption tester (PowerTutor); and correspondingly and respectively acquiring the CPU occupation condition, the memory occupation condition and the disk read-write condition of each time period in the Android virtual machine or the Android real machine of the Android application program to be tested in the running time through the adb shell running performance testing tool top, the performance testing tool vmstat and the performance testing tool iostat in the Eclipse integrated development environment. According to the method, the energy consumption test of each component of the Android terminal can be realized, and meanwhile, the test method can obtain the CPU occupation condition, the memory occupation condition and the disk reading and writing condition information of the Android application program in each time period aiming at the Android terminal, so that a developer can know the global performance of the Android terminal while testing the power consumption of each component of the Android terminal when running the Android application program, and can know the optimization of codes and change the influence on the Android application program energy consumption and the resource occupation of equipment in real time when programming.
(2) According to the energy consumption and performance testing method of the Android application program, the real-time power consumption of the CPU in the Android virtual machine or the Android real machine can be obtained according to the frequency and power relation curves corresponding to various types of Android terminals built in the energy consumption testing tool PowerTutor, so that the power consumption of each time period is obtained through calculation, and then the power consumption of the CPU in the Android virtual machine or the Android real machine for running the tested Android application program is calculated according to the utilization rate of the CPU of the tested Android application program.
(3) According to the energy consumption and performance testing method for the Android application program, after the power consumption of the CPU in the Android virtual machine or the Android real machine for running the tested Android application program is obtained, the power consumption of one method of the Android virtual machine or the CPU in the Android real machine for running the tested Android application program can be calculated according to the utilization rate of each part in the tested Android application program. Therefore, the method provided by the invention can enable a developer to know the power consumption of each method in the detected Android application program in the CPU in more detail, realizes the power consumption monitoring of the application level and the method level, and provides a more definite direction for the developer to optimize the program.
(4) According to the energy consumption and performance testing method for the Android application program, the package name and the working space path of the tested Android application program are configured in the configuration file, the situation that the path needs to be read repeatedly in each testing process is avoided, and the execution efficiency of the testing method is improved.
(5) According to the energy consumption and performance testing method of the Android application program, power and time curve graphs of each component are respectively generated and visualized through an open source drawing type SWT-Chart in an Eclipse integrated development environment, CPU occupation condition information, memory occupation condition and disk reading and writing condition of each time period in an Android virtual machine or an Android real machine in the running time of the Android application program are visualized in the Eclipse integrated development environment, and therefore a developer can obtain energy consumption and performance testing results of the Android application program more visually.
(6) In the energy consumption and performance testing method of the Android application program, a coverage rate tool Emma is added into a plug-in integrated into an Eclipse integrated development environment; the coverage rate tool Emma can collect the coverage rate information of the Android application program to be tested in the testing process by inserting the compiled Java byte code file in the Android application program to be tested, so that the method can simultaneously realize the simultaneous detection of the energy consumption, performance and coverage rate information of the Android application program, and overcomes the defects of dispersion, incomplete integration and poor Android application debugging method in the prior art. In addition, in the method, through the expansion of a tool Marker and a tool Annotation in the Eclipse integrated development environment, the coverage rate information can be visually displayed in the code line of an editor in the Eclipse integrated development environment, and the power consumption information and the corresponding code line of each method of the detected Android application program running in an Android virtual machine or an Android real machine are displayed on a tool Marker panel, so that a developer can more intuitively obtain the coverage rate information of the detected Android application program code, and can more easily find whether the detected Android application program code has the problem that the detected Android application program code is not executed.
Drawings
FIG. 1 is a visual depiction of the power versus time curves for each component and the total power versus time curves for all components generated by the method of the present invention.
FIG. 2 is a visual interface diagram of the CPU occupation situation of the detected Android application program in the Android virtual machine or the Android real machine, which is acquired in the method.
Fig. 3 is a visual interface diagram of memory occupation of the detected Android application program in the Android virtual machine or the Android real machine, which is acquired in the method of the present invention.
Fig. 4 is a visual interface diagram of the hard disk occupation situation of the detected Android application program in the Android virtual machine or the Android real machine, which is acquired in the method provided by the invention.
FIG. 5 is a diagram of a coverage visualization interface implemented by a Marker tool in an Eclipse integrated development environment in the method of the present invention.
Fig. 6 is a power consumption visual interface diagram of each method for running the tested Android application program by the CPU in the Android virtual machine or the Android real machine, which is acquired in the method of the present invention.
Detailed Description
The present invention will be described in further detail with reference to examples and drawings, but the present invention is not limited thereto.
Examples
The embodiment discloses an energy consumption and performance testing method for an Android application program, which is characterized by comprising the following steps:
step S1, integrating plug-ins including an energy consumption testing tool PowerTutor, a performance testing tool top, a performance testing tool vmstat, a performance testing tool iostat, a performance measuring tool procrank and a coverage rate tool Emma in an Eclipse integrated development environment; meanwhile, the package name and the working space path of the tested Android application program are configured in the configuration file; and finding the detected Android application program in an Android virtual machine or an Android real machine through the configured package name and the working space path of the detected Android application program in an Eclipse integrated development environment.
And step S2, operating the plug-in the Eclipse integrated development environment, and installing an energy consumption testing tool PowerTutor into an Android virtual machine or an Android real machine by the plug-in.
Step S3, when the Android application program to be tested runs in the Android virtual machine or the Android real machine, the power consumption of each component in the Android virtual machine or the Android real machine is respectively recorded by a power consumption tester PowerTutor; after the power consumption of each component in the Android virtual machine or the Android real machine is recorded by the energy consumption testing tool PowerTutor, power and time curve graphs of each component of the Android virtual machine or the Android real machine are respectively generated and visualized through an open source drawing type SWT-Chart in an Eclipse integrated development environment. Fig. 1 shows power and time curves of the CPU and the LCD screen when the tested Android application is running, and a total power and time curve of all components when the tested Android application is running.
Meanwhile, a performance testing tool top command line tool is run through the adb shell in the Eclipse integrated development environment, and the CPU occupation condition and the CPU occupation rate of each time period in the Android virtual machine or the Android real machine of the Android application program to be tested in the running time are recorded through the performance testing tool top; and outputting the result to an output path, wherein the output result is reserved for five processes which account for the CPU percentage, and is output once every 6s for 10 times, and one minute in total. The specific commands are as follows:
adb shell top-m 5-n 10-d 6>outputPath
and performing interface visualization on the information of the CPU occupation situation of the tested Android application program recorded by the performance testing tool top in each time period in the Android virtual machine or the Android real machine in the Eclipse integrated development environment in the running time, as shown in fig. 2.
In an Eclipse integrated development environment, a performance testing tool vmstat command line tool is run through an adb shell, and memory occupation conditions of the Android application program to be tested in each time period in an Android virtual machine or an Android real machine in the running time are recorded through the performance testing tool vmstat, wherein the memory occupation conditions comprise a free memory, an occupied memory, an anonymous memory and a slab cache. In this embodiment, the vmstat command line tool is run through the adb shell and the result is output to the output path once every 6s for a total of 10 outputs for a total of one minute. The specific commands are as follows:
adb shell vmstat-n 10-d 6>outputPath
interface visualization is performed on the memory occupation situation information of the tested Android application program recorded by the performance testing tool vmstat in the Android virtual machine or the Android real machine in each time period in the running time in the Eclipse integrated development environment, as shown in fig. 3.
In an Eclipse integrated development environment, a performance testing tool procrask command line tool is run through an adb shell, and the memory occupation condition of each process in each time period in an Android virtual machine or an Android real machine of a tested Android application program in the running time is recorded through the performance testing tool procrask.
The specific commands are as follows:
adb shell/system/xbin/procrank>outputPath
in an Eclipse integrated development environment, a performance testing tool iostat command line tool is run through an adb shell, the disk read-write conditions of the tested Android application program in each time period in an Android virtual machine or an Android real machine in the running time are recorded through the performance testing tool iostat, the disk read-write conditions comprise disk operation activities monitoring and reporting disk activity statistical conditions, and meanwhile, CPU use conditions are also reported. The commands are as follows:
adb root
adb remount
adb push iostatPath/system/bin/
adb shell chmod 755/system/bin/iostat
adb shell iostat-d 6 10>outputPath
performing interface visualization on read-write condition information of a disk of each time period in an Android virtual machine or an Android real machine of a tested Android application program recorded by a performance testing tool iostat in an operating time in an Eclipse integrated development environment, as shown in fig. 4
Meanwhile, in this step, when the Android application program to be tested runs in the Android virtual machine or the Android real machine, the coverage rate tool Emma collects the coverage rate information of the Android application program to be tested in the testing process by inserting the compiled Java bytecode file in the Android application program to be tested. In this embodiment, after the coverage information of the detected Android application program is collected by the coverage tool Emma, the coverage information is visually displayed in a code line of an editor in the Eclipse integrated development environment through expansion of a tool Marker and a tool Annotation in the Eclipse integrated development environment, and the power information and the code line of the method executed this time are displayed on a tool Marker panel, as shown in fig. 5.
In the step S3, when the tested Android application program is running, the power consumption of the CPU, the display screen, the Wi-Fi module, and the 3G network in the Android virtual machine or the Android real machine is respectively recorded by the power consumption testing tool PowerTutor.
In step S3, when the tested Android application runs in the Android virtual machine or the Android real machine, the energy consumption testing tool PowerTutor first obtains the power consumption of the CPU in the Android virtual machine or the Android real machine, and then obtains the power consumption of the CPU in the Android virtual machine or the Android real machine running the tested Android application, and the specific process is as follows:
step S31, firstly, determining the model of the Android virtual machine or the Android real machine where the detected Android application program is located, acquiring a direct relation curve of the frequency and the power of a CPU (Central processing Unit) of Android of the model built in a power consumption testing tool PowerTutor, and obtaining the real-time power consumption of the CPU of the Android virtual machine or the Android real machine where the detected Android application program is located according to the real-time frequency of the Android virtual machine or the Android real machine where the detected Android application program is located through the acquired CPU frequency and power curve;
the relation curve diagram between the frequency and the power of Android terminals of various models is built in the energy consumption testing tool PowerTutor;
step S32, when the power consumption of the CPU in the Android virtual machine or the Android real machine in a certain period of time for running the Android application program to be detected is calculated, accumulating the real-time power consumption of the Android virtual machine or the Android real machine in which the Android application program to be detected is located in the time period to obtain the CPU power consumption of the Android virtual machine or the Android real machine in which the Android application program to be detected is located in the time period
Figure BDA0001522005440000111
Step S33, obtaining the CPU utilization rate util of the tested Android application program when running in the Android virtual machine or the Android real machine, and obtaining the CPU power consumption of the Android virtual machine or the Android real machine of the tested Android application program in the period of time obtained in the step S32
Figure BDA0001522005440000112
Multiplying the CPU utilization rate util of the tested Android application program when the tested Android application program runs in the Android virtual machine or the Android real machine to obtain the CPU Power consumption Power of the tested Android application program when the CPU runs in the Android virtual machine or the Android real machine in the period of timeCPU
Figure BDA0001522005440000113
In step S3, the specific process that the energy consumption testing tool PowerTutor records the power consumption of the WIFI module in the Android virtual machine or the Android real machine is as follows:
step S311, when the tested Android application program runs, acquiring time proportion occupied by four states of the WIFI module per second, wherein the four states refer to a high-power state, a low-power state, a high-power data transmission state and a low-power data transmission data state of the WIFI module; when the number of transmitted packets per second is more than 15, the WiFi module is switched from the low-power data transmission state to the high-power data transmission state, and when the number of transmitted packets per second is less than 8, the WiFi module is switched from the high-power data transmission state to the low-power data transmission state. When the WiFi is in a low-power data transmission state or a high-power transmission state, the power is about 1000mW, the data transmission state of the WiFi module is kept about 10-15 ms every second, and the WiFi module enters the corresponding high-power state or the low-power state in the rest time.
Step S312, correspondingly multiplying the power of the WIFI module in each state in each second operation time by the time proportion occupied by each state in each second, and adding to obtain the real-time power consumption E per second of the WIFI module in the Android virtual machine or the Android real machine:
E=A×a+B×b+C×c+D×d;
a, B, C and D are powers in the WIFI module high power state, low power state, high power data transmission state, and low power data transmission data state, respectively; a. b, c and d are respectively time proportions respectively occupied by the WIFI module in a high-power state, a low-power state, a high-power data transmission state and a low-power data transmission data state every second; wherein
The power A of the WIFI module in the high-power state is as follows:
A=[710mW+βcr(Rchannel)×Rdata];
βcr(Rchannel)=48-0.768×Rchannel
wherein R ischannelFor WIFI Module uplink channel Rate, RdataThe data rate is the WIFI module uplink data rate;
the power B of the WIFI module in the low-power state, the power C of the WIFI module in the high-power data transmission state and the power D of the WIFI module in the low-power data transmission data state are fixed values; in this example, B was 20mW, C and D were 1000mW, and A was calculated to fluctuate in the range of 700mW to 750 mW.
In this embodiment, in step S3, after the power consumption of the CPU in the Android virtual machine or the Android real machine running the tested Android application program in a certain period of time is calculated, the power consumption of the CPU in the Android virtual machine or the Android real machine running a certain method in the tested Android application program in a certain period of time may also be calculated, and the specific process is as follows: firstly, acquiring the utilization rate of a CPU (Central processing Unit) of a tested Android application program when the method runs in an Android virtual machine or an Android real machine, and then multiplying the power consumption of the CPU running the tested Android application program in the Android virtual machine or the Android real machine in the period of time by the utilization rate of the CPU running the method in the Android virtual machine or the Android real machine to obtain the power consumption of one method in the Android application program running of the CPU in the Android virtual machine or the Android real machine in the period of time:
Figure BDA0001522005440000121
obtaining
Figure BDA0001522005440000122
Running the power consumption of the method i in the tested Android application program for the CPU in the Android virtual machine or the Android real machine in the period; utiliAnd (3) the CPU utilization rate of the tested Android application program method i when the tested Android application program method i runs in the Android virtual machine or the Android real machine. As shown in fig. 6, the interface is a visual interface of power consumption of each method in the Android application program to be tested, which is run by the CPU in the Android virtual machine or the Android real machine for a certain period.
The method in the tested Android application program comprises a resource getResources () obtaining method, a window onCreate () generating method, a resource getResources () obtaining method and an array getStringArray () obtaining method.
The above embodiments are preferred embodiments of the present invention, but the present invention is not limited to the above embodiments, and any other changes, modifications, substitutions, combinations, and simplifications which do not depart from the spirit and principle of the present invention should be construed as equivalents thereof, and all such changes, modifications, substitutions, combinations, and simplifications are intended to be included in the scope of the present invention.

Claims (10)

1. An energy consumption and performance testing method for an Android application program is characterized by comprising the following steps:
step S1, integrating plug-ins including a power consumption testing tool PowerTutor, a performance testing tool top, a performance testing tool vmstat and a performance testing tool iostat in an Eclipse integrated development environment;
step S2, running the plug-in an Eclipse integrated development environment, and installing an energy consumption testing tool PowerTutor into an Android virtual machine or an Android real machine by the plug-in;
step S3, when the Android application program to be tested runs in the Android virtual machine or the Android real machine, the power consumption of each component in the Android virtual machine or the Android real machine is respectively recorded by a power consumption tester PowerTutor;
meanwhile, in an Eclipse integrated development environment, running a performance testing tool top, a performance testing tool vmstat and a performance testing tool iostat through an adb shell, recording the CPU occupation situation of each time period of the tested Android application program in the Android virtual machine or the Android real machine in the running time through the performance testing tool top, recording the memory occupation situation of each time period of the tested Android application program in the Android virtual machine or the Android real machine in the running time through the performance testing tool vmstat, and recording the disk reading and writing situation of each time period of the tested Android application program in the Android virtual machine or the Android real machine in the running time through the performance testing tool iostat;
in the step S3, when the Android virtual machine or the Android real machine runs the tested Android application program, the energy consumption testing tool PowerTutor first obtains the power consumption of the CPU in the Android virtual machine or the Android real machine, and then obtains the power consumption of the CPU in the Android virtual machine or the Android real machine running the tested Android application program, and the specific process is as follows:
step S31, firstly, determining the model of the Android virtual machine or the Android real machine where the detected Android application program is located, acquiring a direct relation curve of the frequency and the power of a CPU (Central processing Unit) of Android of the model built in a power consumption testing tool PowerTutor, and obtaining the real-time power consumption of the CPU of the Android virtual machine or the Android real machine where the detected Android application program is located according to the real-time frequency of the Android virtual machine or the Android real machine where the detected Android application program is located through the acquired CPU frequency and power curve;
the relation curve diagram between the frequency and the power of Android terminals of various models is built in the energy consumption testing tool PowerTutor;
step S32, when the power consumption of the CPU in the Android virtual machine or the Android real machine in a certain period of time for running the Android application program to be detected is calculated, accumulating the real-time power consumption of the Android virtual machine or the Android real machine in which the Android application program to be detected is located in the time period to obtain the CPU power consumption of the Android virtual machine or the Android real machine in which the Android application program to be detected is located in the time period
Figure FDA0002384305960000023
Step S33, obtaining the CPU utilization rate util of the tested Android application program when running in the Android virtual machine or the Android real machine, and obtaining the CPU power consumption of the Android virtual machine or the Android real machine of the tested Android application program in the period of time obtained in the step S32
Figure FDA0002384305960000022
Multiplying the CPU utilization rate util of the tested Android application program when the tested Android application program runs in the Android virtual machine or the Android real machine to obtain the CPU Power consumption Power of the tested Android application program when the CPU runs in the Android virtual machine or the Android real machine in the period of timeCPU
Figure FDA0002384305960000021
2. The method for testing energy consumption and performance of Android applications according to claim 1, wherein in step S3, when the Android application to be tested runs in the Android virtual machine or the Android native machine, the energy consumption testing tool PowerTutor records the power consumption of the CPU, the display screen, the Wi-Fi module and the 3G network in the Android virtual machine or the Android native machine, respectively.
3. The Android application energy consumption and performance testing method of claim 1,
in step S3, the specific process that the energy consumption testing tool PowerTutor records the power consumption of the WIFI module in the Android virtual machine or the Android real machine is as follows:
step S311, when the tested Android application program runs, acquiring time proportion occupied by four states of the WIFI module per second, wherein the four states refer to a high-power state, a low-power state, a high-power data transmission state and a low-power data transmission data state of the WIFI module;
step S312, correspondingly multiplying the power of the WIFI module in each state in each second operation time by the time proportion occupied by each state in each second, and adding to obtain the real-time power consumption E per second of the WIFI module in the Android virtual machine or the Android real machine:
E=A×a+B×b+C×c+D×d;
a, B, C and D are powers in the WIFI module high power state, low power state, high power data transmission state, and low power data transmission data state, respectively; a. b, c and d are respectively time proportions respectively occupied by the WIFI module in a high-power state, a low-power state, a high-power data transmission state and a low-power data transmission data state every second; wherein
The power A of the WIFI module in the high-power state is as follows:
A=[710mW+βcr(Rchannel)×Rdata];
βcr(Rchannel)=48-0.768×Rchannel
wherein R ischannelFor WIFI Module uplink channel Rate, RdataThe data rate is the WIFI module uplink data rate;
the power B of the WIFI module in the low-power state, the power C of the WIFI module in the high-power data transmission state and the power D of the WIFI module in the low-power data transmission data state are fixed values.
4. The method for testing energy consumption and performance of the Android application program according to claim 1, wherein the step S3 further comprises the following step of calculating power consumption of a certain method in the Android application program to be tested operated by the CPU in the Android virtual machine or the Android real machine in a certain period, and the specific process is as follows: firstly, the utilization rate of a CPU (Central processing Unit) of a tested Android application program in the running process of an Android virtual machine or an Android real machine is obtained, then the power consumption of the CPU of the Android virtual machine or the Android real machine in the period of time for running the tested Android application program is multiplied by the utilization rate of the CPU of the tested Android application program in the running process of the method of the Android virtual machine or the Android real machine, and the power consumption of a certain method in the Android application program running of the CPU of the Android virtual machine or the Android real machine in the period of time is obtained.
5. The method for testing energy consumption and performance of Android applications according to claim 1, wherein in step S1, the plug-in integrated into the Eclipse integrated development environment further includes a performance measurement tool procrask, when the Android application to be tested runs in the Android virtual machine or the Android real machine, the performance measurement tool procrask is run in the Eclipse integrated development environment through an adb shell, and the memory occupation status of each process in each time period in the Android virtual machine or the Android real machine of the Android application to be tested in the running time is recorded through the performance measurement tool procrask.
6. The method for testing the energy consumption and the performance of the Android application program according to claim 1, characterized by further comprising the following steps: configuring a package name and a working space path of the tested Android application program in a configuration file; and finding the detected Android application program in an Android virtual machine or an Android real machine through the configured package name and the working space path of the detected Android application program in an Eclipse integrated development environment.
7. The method for testing the energy consumption and the performance of the Android application program according to claim 1, wherein in step S3, after the energy consumption testing tool PowerTutor records the power consumption of each component in the Android virtual machine or the Android real machine, a power and time curve graph of each component is respectively generated and visualized through an open source drawing type SWT-Chart in an Eclipse integrated development environment.
8. The method for testing energy consumption and performance of Android application programs according to claim 1, wherein in step S3, CPU occupation status information of the tested Android application program recorded by the performance testing tool top in each time period in the Android virtual machine or the Android real machine is visualized in an Eclipse integrated development environment during the running time;
visualizing the memory occupation condition information of the tested Android application program recorded by the performance testing tool vmstat in the Android virtual machine or the Android real machine in each time period in the running time in an Eclipse integrated development environment;
and visualizing the disk read-write condition information of the tested Android application program recorded by the performance testing tool iostat in each time period in the Android virtual machine or the Android real machine in the Eclipse integrated development environment in the running time.
9. The method for testing energy consumption and performance of Android applications of claim 1, wherein in step S1, the plug-in integrated into the Eclipse integrated development environment further comprises a coverage tool Emma;
in step S3, when the Android virtual machine or the Android real machine runs the Android application program to be tested, the coverage rate tool Emma collects coverage rate information of the Android application program to be tested in the test process by inserting the Java bytecode file compiled in the Android application program to be tested.
10. The method for testing the energy consumption and the performance of the Android application program according to claim 9, characterized in that after the coverage information of the Android application program to be tested is collected by the coverage tool Emma, the coverage information is visually displayed on a code line of an editor in the Eclipse integrated development environment through development of a tool Marker and a tool Annotation in the Eclipse integrated development environment, and power consumption information and a corresponding code line of each method of the Android application program to be tested, which runs in an Android virtual machine or an Android real machine, are displayed on a tool Marker panel.
CN201711415982.0A 2017-12-25 2017-12-25 Energy consumption and performance test method for Android application program Active CN107977318B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201711415982.0A CN107977318B (en) 2017-12-25 2017-12-25 Energy consumption and performance test method for Android application program

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201711415982.0A CN107977318B (en) 2017-12-25 2017-12-25 Energy consumption and performance test method for Android application program

Publications (2)

Publication Number Publication Date
CN107977318A CN107977318A (en) 2018-05-01
CN107977318B true CN107977318B (en) 2020-07-03

Family

ID=62007621

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201711415982.0A Active CN107977318B (en) 2017-12-25 2017-12-25 Energy consumption and performance test method for Android application program

Country Status (1)

Country Link
CN (1) CN107977318B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112711521A (en) * 2021-03-25 2021-04-27 浙江华创视讯科技有限公司 Automatic performance testing method and system

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108710572A (en) * 2018-05-16 2018-10-26 云南大学 Consumption information collection method under the test of android system automatic pressure
CN108833491A (en) * 2018-05-24 2018-11-16 朔联科技(上海)有限公司 The energy consumption statistical method and server of Internet of things system
CN115576856B (en) * 2022-12-08 2023-04-11 浪潮通信信息系统有限公司 Energy consumption evaluation method and device

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2014205788A1 (en) * 2013-06-28 2014-12-31 深圳市掌讯通讯设备有限公司 Method for automatically synchronizing data between android intelligent devices

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2014205788A1 (en) * 2013-06-28 2014-12-31 深圳市掌讯通讯设备有限公司 Method for automatically synchronizing data between android intelligent devices

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
Smartphone Energy Consumption Of Multimedia Services In Heterogeneous Wireless Networks;Ross Andreucetti,etc.;《2014 International Wireless Communications and Mobile Computing Conference (IWCMC)》;20140808;1-5 *
一种开源嵌入式Linux集成开发环境定制;孙洁等;《电子工程师》;20070430;第33卷(第4期);1-3 *

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112711521A (en) * 2021-03-25 2021-04-27 浙江华创视讯科技有限公司 Automatic performance testing method and system

Also Published As

Publication number Publication date
CN107977318A (en) 2018-05-01

Similar Documents

Publication Publication Date Title
CN107977318B (en) Energy consumption and performance test method for Android application program
EP2976715B1 (en) Application testing and analysis
CN108717393A (en) A kind of applied program testing method and mobile terminal
Peltonen et al. Energy modeling of system settings: A crowdsourced approach
CN104636240B (en) A kind of acquisition methods and terminal of information report
CN104932963B (en) The method and device of management terminal
CN105302714A (en) Method and apparatus for monitoring memory leak in test process
CN109101397A (en) High-Performance Computing Cluster monitoring method, unit and storage medium
CN105025141A (en) Method and device for testing electricity consumption of terminal
CN104951400A (en) Method and device for testing product
CN114167132B (en) Power consumption detection method and device of wireless terminal, electronic equipment and storage medium
CN105279067A (en) Method and device for reporting information
Tu et al. Unveiling energy efficiency in deep learning: Measurement, prediction, and scoring across edge devices
Creus et al. Optimizing mobile software with built-in power profiling
CN111104281B (en) Game performance monitoring method, device, system and storage medium
CN110334385B (en) Test method, device and equipment for central controller of comprehensive energy system
CN107506275B (en) Software protection energy consumption evaluation method based on ARM instruction virtualization
Kamiyama et al. A model-based energy profiler using online logging for Android applications
CN114443461A (en) Method, device, system and medium for determining code coverage information
JP2023537119A (en) Network data analysis method, network data analysis function network element, communication system, non-transitory computer readable storage medium and computer program
Skretting et al. Baseline for performance prediction of android applications
Nabi et al. Assessing the benefits of computational offloading in mobile-cloud applications
CN113760672A (en) Performance test method, equipment and storage medium for multi-cloud platform resources
Fischer et al. Sema: An approach based on internal measurement to evaluate energy efficiency of android applications
CN111044925A (en) Simulator for battery detection system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant