本文主要是记录笔者接入微信性能监控框架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

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

被折叠的 条评论
为什么被折叠?



