Android客户端性能测试实践

/ Java / 0 条评论 / 788浏览
1. App cpu memory(Android Studio) [http://www.cnblogs.com/shytong/p/5262585.html][1] 2. 电量battery-historian(python2.7) [https://bathist.ef.lc/][2] 在线分析地址
软件支持:python2.7, git, go
[https://golang.org/doc/install?download=go1.12.1.windows-amd64.msi][3]
battery-historian安装:
1> go get -d -u github.com/google/battery-historian/...
2> cd workspace路径, 执行go run setup.go
注:setup.go主要是下载third-party包然后编译执行
可以手动到git路径下载解压,下载同一日期release版本即可(compiler+library)
(thirdparty 修改setup.go compiler版本为 closureCompilerVersion = "20170626"下载library 同样日期的版本)
3> go run cmd/battery-historian/battery-historian.go
注:可以指定port,不指定的话默认9999
4> 登录网址 http://localhost:9999 就可以上传report进行解析
日志解析过程:
i. reset
adb shell dumpsys batterystats --enable full-wake-history
adb shell dumpsysbatterystats –reset
ii. 启动应用,正常进行操作
iii. cmd执行“adb bugreport > bugreport.txt”运行完成为止
或者用下面的命令也可以:
adb shell dumpsys batterystats > batterystats.txt
adb shell dumpsys batterystats > com.example.android.sunshine.app >batterystats.txt
iv.上传 bugreport.txt 文件至 http://localhost:9999 完成后即可查看图表信息
3.启动时间 + 安装耗时 adb shell am start -W com.meizu.media.painter/com.meizu.media.painter.PainterMainActivity * WaitTime 返回从 startActivity 到应用第一帧完全显示这段时间. 就是总的耗时,包括前一个应用 Activity pause 的时间和新应用启动的时间; * ThisTime 表示一连串启动 Activity 的最后一个 Activity 的启动耗时; * TotalTime 表示新应用启动的耗时,包括新进程的启动和 Activity 的启动,但不包括前一个应用Activity pause的耗时。 4. Emmagee
[https://github.com/NetEase/Emmagee/releases][4]
监控单个App的CPU,内存,流量,启动耗时,电量,电流等很多性能状态的变化
1> 登录、更新状态带宽占用低于100Kbps,终端在线运行平均带宽占用量低于1Kpbs
2>内存占用量不超过100M
3>一个完整充放电周期内,平均CPU使用率不超过1%
5. 容器应用
U-Space启动应用个数10个 APP安装时间统计 public class InstallTime { public static void main(String[] args) { //apk名字 String str="AEMM-5.2.0.520000396.apk";//gpstest-1.2.2.apk //abd 安装指令 String command1 ="adb install -r " + str; //安装时会出现log,根据关键字确定何时安装,何时结束 Runtime runtime = Runtime.getRuntime(); double totalTime = 0; double pushTime = 0; try { //执行命令,有一段传输数据的时间,不能计算在内 Process getSIBaseVersionProcess2 = runtime.exec(command1); long startTime=System.currentTimeMillis(); BufferedReader bufferedReader = new BufferedReader(new InputStreamReader( getSIBaseVersionProcess2.getInputStream())); String SIBaseVersion = " "; while((SIBaseVersion =bufferedReader.readLine())!=null){ System.out.println(SIBaseVersion); if (SIBaseVersion.contains("bytes in")) { //取push时间 String sub = SIBaseVersion.substring(SIBaseVersion.indexOf("bytes in")+9, SIBaseVersion.length()-2); pushTime = Double.parseDouble(sub); //System.out.println("PushTime: " + pushTime); } //安装成功 if (SIBaseVersion.equals("Success")) { //时间 long endTime=System.currentTimeMillis(); long time = endTime-startTime; totalTime =1.0* time/1000; //System.out.println("TotalTime: " + totalTime); } } } catch (Exception e) { System.out.println("[Error][Install]" + e.getMessage()); } System.err.println("Time="+(totalTime-pushTime)+" S"); } } [1]: http://www.cnblogs.com/shytong/p/5262585.html [2]: https://bathist.ef.lc/ [3]: https://golang.org/doc/install?download=go1.12.1.windows-amd64.msi [4]: https://github.com/NetEase/Emmagee/releases