当前位置:网站首页>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 namestop 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 namestop 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
边栏推荐
- 《MATLAB 神经网络43个案例分析》:第10章 离散Hopfield神经网络的分类——高校科研能力评价
- Echart柱状图:echart实现堆叠柱状图
- Use of Nacos configuration center
- [spark]spark introductory practical series_ 8_ Spark_ Mllib (upper)__ Introduction to machine learning and sparkmllib
- 智能数字资产管理助力企业决胜后疫情时代
- 杨辉三角形详解
- [written examination questions of meituan]
- Applet export (use) public function, public data
- Wechat applet custom tabbar (session customer service) vant
- php 分布式事务 原理详解
猜你喜欢
![[compilation and assembly link] coff file and structure description](/img/73/fca3752327c31877ea8f56f96c009e.jpg)
[compilation and assembly link] coff file and structure description

Echart line chart: multiple line charts show only one line at a time
![[to]12 common IP commands in the iproute installation package](/img/65/a214d137e230b1a1190feb03660f2c.jpg)
[to]12 common IP commands in the iproute installation package

Complete USB debugging assistant

AI realizes "Resurrection" of relatives | old photo repair | old photo coloring, recommended by free app

USB debugging assistant

Pod libwebp error reporting solution

华为开发者认证与DevEco Studio编译器下载

Learning records countless questions (JS)

Explication détaillée du triangle Yang hui
随机推荐
Binary search
【美团笔试题】
Uni app dynamic setting title
Echart柱状图:堆叠柱状图value格式化显示
万能播放器 PotPlayer 的下载与安装,直播流 m3u8 导入
Applet export (use) public function, public data
Local file search tool everything
USB status error and its cause (error code)
本地文件秒搜工具 Everything
自定义View —— 可伸展的CollapsExpendView
Printf function
Echart histogram: stack histogram value formatted display
A glimpse of [wechat applet]
The boys x pubgmobile linkage is coming! Check out the latest game posters
You still can't remotely debug idea? Come and have a look at my article. It's easy to use
JVM Foundation
Echart矩形树图:简单实现矩形树图
【var const let区别】
You should consider upgrading via
Wechat applet uploads pictures (preview deletion limits the size and number of pictures)