Android 接入微信性能监控框架Matrix实践

本文详述了接入微信Matrix性能监控框架的步骤,包括在gradle文件中配置,应用MatrixGradle插件,初始化Matrix并启用TraceCanary和IOCanary。同时,文章介绍了如何分析Matrix输出的慢方法监控、ANR监控、启动速度监控和帧率监控数据,以提升应用性能。

本文主要是记录笔者接入微信性能监控框架Matrix的过程,以及简单阐述如何分析Matrix输出的监控数据。

一、接入步骤

1. 项目的根目录下的gradle.properties文件声明接入Matrix的版本

lib_thirds_matrix_version=2.0.8

2. 项目的根目录下的build.gradle文件 声明Matrix Gradle 插件

buildscript {
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:4.2.2"
       
        classpath ("com.tencent.matrix:matrix-gradle-plugin:${lib_thirds_matrix_version}") { changing = true }
     
    }
}

3. 在app build.gralde文件声明apply Matrix插件

apply plugin: 'com.tencent.matrix-plugin'
matrix {
    trace {
        enable = true	//if you don't want to use trace canary, set false
        baseMethodMapFile = "${project.buildDir}/matrix_output/Debug.methodmap"
        blackListFile = "${project.projectDir}/matrixTrace/blackMethodList.txt"
    }
}

4. 在项目接入Matrix的Module 进行依赖

一般我们是在app module下的build.gradle进行依赖,但是笔者比较喜欢按功能划分module,所以新建一个Module: apmlib, 并且在apmlib的build.gradle下进行依赖。

dependencies {
    //按需依赖需要的canary
    implementation group: "com.tencent.matrix", name: "matrix-android-lib", version: lib_thirds_matrix_version, changing: true
    implementation group: "com.tencent.matrix", name: "matrix-android-commons", version: lib_thirds_matrix_version, changing: true
    implementation group: "com.tencent.matrix", name: "matrix-trace-canary", version: lib_thirds_matrix_version, changing: true
    implementation group: "com.tencent.matrix", name: "matrix-io-canary", version: lib_thirds_matrix_version, changing: true
//    implementation group: "com.tencent.matrix", name: "matrix-memory-canary", version: lib_thirds_matrix_version, changing: true
//    implementation group: "com.tencent.matrix", name: "matrix-resource-canary-android", version: lib_thirds_matrix_version, changing: true
//    implementation group: "com.tencent.matrix", name: "matrix-resource-canary-common", version: lib_thirds_matrix_version, cha
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值