当前位置:网站首页>App performance test: (II) CPU
App performance test: (II) CPU
2022-06-13 06:16:00 【Ming ruoxiao River】
app Performance testing :( Two )CPU
Following pair CPU Analyze :
see CPU usage ( First, you need to open the corresponding app)
command :adb shell top -n 1 | findstr Package name
Running resultsPID UID PR CPU% S #THR VSS RS PCY packageName 28210 u0_a129 10 -10 18% S 42 1814932K 160848K fg Package name
Name | meaning |
---|---|
PID | process ID |
UID | process ID |
PR | priority |
CPU% | The present moment takes up CPU percentage |
S | Process status (R= function ,S= sleep ,T= track / stop it ,Z= Zombie process ) |
#THR | Number of threads |
VSS | Virtual Set Size Virtual memory consumption ( Contains the memory used by the shared library ) |
RSS | Resident Set Size Actually using physical memory ( Contains the memory used by the shared library ) |
PCY | Scheduling policy priority ,SP_BACKGROUND/SPFOREGROUND |
NAME | Process name |
top The command also supports some command line parameters , The detailed usage is as follows :
Usage: top [ -m max_procs ] [ -n iterations ] [ -d delay ] [ -s sort_column ] [ -t ] [ -h ]
-m num Show at most how many processes
-n num Refresh how many times and exit
-d num Refresh interval ( Unit second , The default value is 5)
-s col Sort by a column ( You can use col value :cpu, vss, rss, thr)
-t Show thread information
-h Show help documents
Monitoring script code
#/usr/bin/python
#encoding:utf-8
import csv
import os
import time
# The control class
class Controller(object):
def __init__(self, count):
self.counter = count
self.alldata = [("timestamp", "cpustatus")]
# Single test process
def testprocess(self):
result = os.popen("adb shell top -n 1 | findstr com.zahd.agriculturaltraceability.debug")
# Run the command to get : 30464 u0_a129 10 -10 22% S 44 1823308K 158792K fg ...
for line in result.readlines():
cpuvalue = line.split("%")[0] #30464 u0_a129 10 -10 24 for line in result.readlines():
result1 = line.split("%")[0]# obtain 30464 u0_a129 10 -10 24
result2=result1.split(" ")# Separate by spaces
cpuvalue=result2[len(result2)-1]# Get the last... Of the array , That is to say cpu%
currenttime = self.getCurrentTime()
self.alldata.append((currenttime, cpuvalue))
# Perform the test process multiple times
def run(self):
while self.counter >0:
self.testprocess()
self.counter = self.counter - 1
time.sleep(3)
# Get the current timestamp
def getCurrentTime(self):
currentTime = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
return currentTime
# Data storage
def SaveDataToCSV(self):
csvfile = open('cpustatus.csv', 'w')
writer = csv.writer(csvfile)
writer.writerows(self.alldata)
csvfile.close()
if __name__ == "__main__":
controller = Controller(10)
controller.run()
controller.SaveDataToCSV()
Monitoring process , Manual operation required app
边栏推荐
- Uni app provincial and urban linkage
- MySQL custom function
- Uniapp hides the scroll bar of scroll view
- You should consider upgrading via
- Security baseline check script - the road to dream
- Echart柱状图:堆叠柱状图显示value
- 智能数字资产管理助力企业决胜后疫情时代
- Sqlplus connection failure
- USB 0xc0000011 error
- Custom view - extensible collapsexpendview
猜你喜欢
Echart折线图:当多条折线图的name一样时也显示不同的颜色
万能播放器 PotPlayer 的下载与安装,直播流 m3u8 导入
Status management --provider
[spark]spark introductory practical series_ 8_ Spark_ Mllib (upper)__ Introduction to machine learning and sparkmllib
Sqlplus connection failure
Echart histogram: stack histogram value formatted display
1+1>2,Share Creators可以帮助您实现
The Boys x PUBGMOBILE 联动火热来袭!来看最新游戏海报
A glimpse of [wechat applet]
Solutions to common problems in small program development
随机推荐
超有范的 logo 在线设计制作工具
Learning records countless questions (JS)
Echart折线图:当多条折线图的name一样时也显示不同的颜色
Waterfall flow layout of uni app Homepage
Adding classes dynamically in uni app
The difference between the increment and decrement operators before and after variables i+, +i, I –, – I
Echart line chart: when multiple lines have the same name, the legend is still displayed
[compilation and assembly link] coff file and structure description
High burst solution 2
Echart折线图:当多条折线存在相同name,图例仍全部显示
Echart histogram: stack histogram value formatted display
智能数字资产管理助力企业决胜后疫情时代
Applet export (use) public function, public data
Free screen recording software captura download and installation
【ONE·Data || 带头双向循环链表简单实现】
[JS] array flattening
FusionPBX 安装 —— 筑梦之路
[JS] handwriting call(), apply(), bind()
Custom view
Echart histogram: echart implements stacked histogram