BlockScanary --监视主线程上卡顿工具


作者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;
    }

}



3.应用的application里面oncreate方法下要加

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




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值