2、获取APP CPU占用率
前面已经介绍过如何获取包名和主活动名。这里不再过多赘述。我们依旧采取两种方案实现APP CPU占有率
Windows下获取APP CPU占用率
adb shell "dumpsys cpuinfo | grep com.begoit.studyplan"
python脚本实现APP 冷/热启动时间
#/usr/bin/python
#encoding:utf-8
import csv
import os
import time #控制类
class Controller(object):
def __init__(self, count):
self.counter = count
self.alldata = [("timestamp", "cpustatus")] #单次测试过程
def testprocess(self):
result = os.popen('adb shell "dumpsys cpuinfo | grep com.begoit.studyplan"')
for line in result.readlines():
cpuvalue = line.split("%")[0] currenttime = self.getCurrentTime()
self.alldata.append((currenttime, cpuvalue)) #多次执行测试过程
def run(self):
while self.counter >0:
self.testprocess()
self.counter = self.counter - 1
time.sleep(3) #获取当前的时间戳
def getCurrentTime(self):
currentTime = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
return currentTime #数据的存储
def SaveDataToCSV(self):
csvfile = file('cpustatus.csv', 'wb')
writer = csv.writer(csvfile)
writer.writerows(self.alldata)
csvfile.close() if __name__ == "__main__":
controller = Controller(10)
controller.run()
controller.SaveDataToCSV()
运行结果展示:
2、获取APP CPU占用率的更多相关文章
- 3、获取APP 内存占用率
关于APP内存占用,不用多说,应该是APP性能测试中比较重要的一点.试想一下,开个应用把手机内存占满了,其它应用无法打开,那么这个应用还会有人安装吗?我觉得是没有的.下面就通过adb命令获取APP虚存 ...
- 获取进程CPU占用率
获取进程CPU占用率 // 时间转换 static __int64 file_time_2_utc(const FILETIME* ftime) { LARGE_INTEGER li; li.LowP ...
- WMI获取进程CPU占用率
Monitor % Process CPU Usage (specific process) http://www.tek-tips.com/viewthread.cfm?qid=395765 for ...
- liteos CPU占用率(十六)
1. 概述 1.1 基本概念 CPU(中央处理器, Central Processing Unit)占用率可以分为系统CPU占用率和任务CPU占用率两种. 系统CPU占用率(CPU Percent)是 ...
- 关于app的cpu占用率想到的几个问题
1.top 命令获取的cpu是手机瞬间的cpu 2.dumpsys获取的是一段时间cpu的平均值?那么这段时间是指哪段,从哪开始到什么时候结束? 3.如果想测试app某操作下的cpu占用情况时候.应该 ...
- C#获取CPU占用率、内存占用、磁盘占用、进程信息
代码: using System; using System.Collections.Generic; using System.Diagnostics; using System.Threading ...
- CPU占用率呈正弦实现,及实时输出进程和线程的CPU占用率
CPU占用率呈正弦实现,及实时输出进程和线程的CPU占用率 #include "stdafx.h" #include <windows.h> #include < ...
- Linux下如何查看高CPU占用率线程
转于:http://www.cnblogs.com/lidabo/p/4738113.html 目录(?)[-] proc文件系统 proccpuinfo文件 procstat文件 procpidst ...
- linux top命令中各cpu占用率含义
linux top命令中各cpu占用率含义 [尊重原创文章摘自:http://www.iteye.com/topic/1137848]0.3% us 用户空间占用CPU百分比 1.0% sy 内核空间 ...
随机推荐
- python random模块随机取list中的某个值
import random from random import randint ''' random.randint()随机生一个整数int类型,可以指定这个整数的范围,同样有上限和下限值,pyth ...
- 用JOptionPane类实现各种对话框
用JOptionPane类实现各种对话框 运行结果: 下面部分参考: JOptionPane类提示框的一些常用的方法 - - ITeye博客 http://847353020-qq-com.itey ...
- linux kafka进程挂了 自动重启
使用crontab,定时监控 kafka进程,发现挂了后重启. shell脚本如下: #!/bin/sh source /etc/profile proc_dir="/data/kafka& ...
- Java Freemarker生成word
Java Freemarker生成word freeMaker 简介: FreeMarker是一款模板引擎: 即一种基于模板和要改变的数据, 并用来生成输出文本(HTML网页.电子邮件.配置文件.源代 ...
- java.net.BindException: Address already in use: 解决方法
java.net.BindException: Address already in use: 解决方法 1. 执行cmd 2. cmd命令模式下输入netstat -ano,然后找到占用端口的那 ...
- Web RTC + audio API 实现录音,并压缩
<button onclick="record()">开始录音</button> <button onclick="stopRecord() ...
- Django 自定义模型管理器(Manager)及方法
转载自:https://www.cnblogs.com/sui776265233/p/11571418.html 1.自定义管理器(Manager) 在语句Book.objects.all()中,ob ...
- 02、python的基础-->占位符、while...else...、逻辑运算符
1.%s.%d格式化输出程序(%占位符,s字符串,d数字) name = input('请输入姓名:') age = input('请输入年龄:') job = input('请输入工作:') hob ...
- 基于rem的移动端响应式适配方案(详解) 移动端H5页面的设计稿尺寸大小规范
基于rem的移动端响应式适配方案(详解) : https://www.jb51.net/article/118067.htm 移动端H5页面的设计稿尺寸大小规范 http://www.tuyiyi.c ...
- [已解决]报错: Version in docker-compose is unsupported
docker compose将解析版本为"2",而不是"3.3".应该改为: version: "2"
