当前位置:网站首页>App performance test: (I) startup time
App performance test: (I) startup time
2022-06-13 06:16:00 【Ming ruoxiao River】
app The performance test is mainly divided into :
Starting time ,CPU, Traffic , Electric quantity , Memory ,FPS, Over rendering
First, the startup time is analyzed :
app The startup of is divided into cold startup ( Create... For the first time ), Hot start ( Through the return key ,home Push the key to the background , Not completely killed )
First, the startup time is analyzed :
Cold start
start-up app command
adb shell am start -W -n Package name /Activity name
stop it app command
adb shell am force-stop Package name
Hot start
start-up app The command is the same as the cold start command
adb shell am start -W -n Package name /Activity name
stop it app command
adb shell input keyevent 3
obtain app Package name command (win10 Next )
adb logcat | findstr "START"
Then click Start app, Can cmp=(…/…) notice app The package name and app Start page of
Script code :
#/usr/bin/python
#encoding:utf-8
import csv
import os
import time
#app class
class App(object):
def __init__(self):
self.content = ""
self.startTime = 0
# start-up App
def LaunchApp(self):
cmd = 'adb shell am start -W -n com.zahd.agriculturaltraceability.debug/com.zahd.agriculturaltraceability.ui.Activity.LoginActivity'
self.content=os.popen(cmd)
# stop it App
def StopApp(self):
#cmd = 'adb shell am force-stop com.zahd.agriculturaltraceability.debug'
cmd = 'adb shell input keyevent 3'
os.popen(cmd)
# Get start time
def GetLaunchedTime(self):
for line in self.content.readlines():
if "ThisTime" in line:
self.startTime = line.split(":")[1]
break
return self.startTime
# The control class
class Controller(object):
def __init__(self, count):
self.app = App()
self.counter = count
self.alldata = [("timestamp", "elapsedtime")]
# Single test process
def testprocess(self):
self.app.LaunchApp()
print("1")
time.sleep(5)
elpasedtime = self.app.GetLaunchedTime()
self.app.StopApp()
time.sleep(3)
currenttime = self.getCurrentTime()
self.alldata.append((currenttime, elpasedtime))
# Perform the test process multiple times
def run(self):
while self.counter >0:
self.testprocess()
self.counter = self.counter - 1
# 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('startTime2.csv', mode='w')
writer = csv.writer(csvfile)
writer.writerows(self.alldata)
csvfile.close()
if __name__ == "__main__":
controller = Controller(10)
controller.run()
controller.SaveDataToCSV()
Expand
Power key : adb shell input keyevent 26
HOME key : adb shell input keyevent 3
Return key : adb shell input keyevent 4
Light up the screen : adb shell input keyevent 224
Turn off the screen : adb shell input keyevent 223
Input text : adb shell input text xxxxx
边栏推荐
- High burst solution 2
- [one · data 𞓜 simple implementation of the leading two-way circular linked list]
- Free screen recording software captura download and installation
- JVM Foundation
- php redis 制作高迸发秒杀
- 1+1>2,Share Creators可以帮助您实现
- 二分查找
- Fichier local second Search Tool everything
- Uniapp secondary encapsulates uview components, and the parent component controls display and hiding
- Uni app dynamic setting title
猜你喜欢
[one · data 𞓜 simple implementation of the leading two-way circular linked list]
Echart histogram: echart implements stacked histogram
1+1 > 2, share creators can help you achieve
微信小程序:基础复习
《MATLAB 神经网络43个案例分析》:第11章 连续Hopfield神经网络的优化——旅行商问题优化计算
Wechat applet (get location)
Echart柱状图:echart实现堆叠柱状图
Solution: vscode open file will always overwrite the last opened label
The Boys x PUBGMOBILE 联动火热来袭!来看最新游戏海报
AI实现亲人“复活”|老照片修复|老照片上色,免费APP推荐
随机推荐
Swift--function
【var const let区别】
微信小程序:基础复习
Uniapp hides the scroll bar of scroll view
Uni app upload file
Minimum spanning tree (prim+kruskal) learning notes (template +oj topic)
电镀挂具RFID工序管理解决方案
Regular verification of mobile phone number, landline email ID card
Pod libwebp error reporting solution
High burst solution 2
Detailed explanation of PHP distributed transaction principle
The Boys x PUBGMOBILE 联动火热来袭!来看最新游戏海报
Uniapp secondary encapsulates uview components, and the parent component controls display and hiding
Commit specification
Wechat applet development (requesting background data and encapsulating request function)
Applet Use of spaces
Applet export (use) public function, public data
Cmake add -fpic option GCC
Echart柱状图:堆叠柱状图value格式化显示
PHP redis makes high burst spike