https://github.com/nekocode/asm-systrace
A plugin to inject tracing code to specified methods.
https://github.com/nekocode/asm-systrace
android gradle-plugin
Last synced: about 2 months ago
JSON representation
A plugin to inject tracing code to specified methods.
- Host: GitHub
- URL: https://github.com/nekocode/asm-systrace
- Owner: nekocode
- License: apache-2.0
- Created: 2018-05-06T11:57:49.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-08-21T08:09:31.000Z (over 7 years ago)
- Last Synced: 2025-03-20T17:23:33.657Z (9 months ago)
- Topics: android, gradle-plugin
- Language: Java
- Homepage:
- Size: 142 KB
- Stars: 37
- Watchers: 3
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# README
[](http://www.apache.org/licenses/LICENSE-2.0.html) [](https://jitpack.io/#nekocode/ASM-Systrace)
This plugin can inject `Trace.beginSection()` & `Trace.endSection` to the methods which you specify in build-time. It's useful when you want to trace the methods of third-party libraries.
In addition, this plugin supports incremental work. So its build performance is not bad.
## Intergation
Intergate this gralde plugin:
```gradle
buildscript {
repositories {
maven { url "https://jitpack.io" }
}
dependencies {
classpath "com.github.nekocode:ASM-Systrace:${lastest-verion}"
}
}
```
Create a groovy script and define two filter methods inside:
```groovy
// Only handle the class you specify can speed up the build
static boolean filterClass(
String className // Example: android/support/v4/app/Fragment
) {
// Return true if you want to continue filter methods in this class
return className.startsWith('cn/nekocode/asm_systrace/example/SomeClass')
}
static String filterMethod(
String className, // Example: android/support/v4/app/Fragment
String methodName, // Example: getLayoutInflater
String methodDesc // Example: (Landroid/os/Bundle;)Landroid/view/LayoutInflater
) {
if (methodName != 'b') return null // Retrun null to skip this method
return className.split('/').last() + '#' + methodName // Return tracing tag
}
```
Apply and configure the plugin:
```gralde
apply plugin: 'asm-systrace'
asmSystrace {
filterScript = project.file("filter.groovy") // The script you created in the pervious step
}
```