作者git地址:https://github.com/markzhai/AndroidPerformanceMonitor/blob/master/README_CN.md
使用步骤:
1. build.gradle 配置
dependencies { compile 'com.github.markzhai:blockcanary-android:1.5.0' // 仅在debug包启用BlockCanary进行卡顿监控和提示的话,可以这么用 debugCompile 'com.github.markzhai:blockcanary-android:1.5.0' releaseCompile 'com.github.markzhai:blockcanary-no-op:1.5.0' }
2.配置监控上下文
可以配置 监控阀值,应用标识符 ,网络类型,用户的id,log保存位置等
public class AppBlockCanaryContext extends BlockCanaryContext {
public int provideBlockThreshold() { //设置监控阀值
return 1000;
}
public String providePath() { //设置log保存位置
String path = "/test/log/looper/";
return path;
}
}
BlockCanary.install(this, new AppBlockCanaryContext()).start();
一些属性的解读:
cpuCore:手机cpu个数。
processName:应用包名。
freeMemory: 手机剩余内存,单位KB。
totalMemory: 手机内训总和,单位KB。
timecost: 该Message(事件)执行时间,单位 ms。
threadtimecost: 该Message(事件)执行线程时间(线程实际运行时间,不包含别的线程占用cpu时间),单位 ms。
cpubusy: true表示cpu负载过重,false表示cpu负载不重。cpu负载过重导致该Message(事件) 超时,错误不在本事件处理上。
参考资料
https://juejin.im/post/599300596fb9a0247537bc1e?utm_source=tuicool&utm_medium=referral
http://blog.csdn.net/swordgirl2011/article/details/52264449