Trace Gradle Plugin

Gradle plugin for method invocation tracing

License

License

Categories

Categories

Gradle Build Tools
GroupId

GroupId

com.sdklite.trace
ArtifactId

ArtifactId

gradle-plugin
Last Version

Last Version

0.0.3
Release Date

Release Date

Type

Type

jar
Description

Description

Trace Gradle Plugin
Gradle plugin for method invocation tracing
Project URL

Project URL

https://github.com/sdklite/trace
Project Organization

Project Organization

SDKLite
Source Code Management

Source Code Management

https://github.com/sdklite/trace.git

Download gradle-plugin

How to add to project

<!-- https://jarcasting.com/artifacts/com.sdklite.trace/gradle-plugin/ -->
<dependency>
    <groupId>com.sdklite.trace</groupId>
    <artifactId>gradle-plugin</artifactId>
    <version>0.0.3</version>
</dependency>
// https://jarcasting.com/artifacts/com.sdklite.trace/gradle-plugin/
implementation 'com.sdklite.trace:gradle-plugin:0.0.3'
// https://jarcasting.com/artifacts/com.sdklite.trace/gradle-plugin/
implementation ("com.sdklite.trace:gradle-plugin:0.0.3")
'com.sdklite.trace:gradle-plugin:jar:0.0.3'
<dependency org="com.sdklite.trace" name="gradle-plugin" rev="0.0.3">
  <artifact name="gradle-plugin" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.sdklite.trace', module='gradle-plugin', version='0.0.3')
)
libraryDependencies += "com.sdklite.trace" % "gradle-plugin" % "0.0.3"
[com.sdklite.trace/gradle-plugin "0.0.3"]

Dependencies

compile (2)

Group / Artifact Type Version
org.javassist : javassist jar 3.20.0-GA
commons-io : commons-io jar 2.4

provided (2)

Group / Artifact Type Version
com.android.tools.build : transform-api jar 1.5.0
com.android.tools.build : gradle jar 1.5.0

Project Modules

There are no modules declared in this project.

Trace

Trace is a gradle plugin for android project to trace java method invocation, it uses the Transform API and Javassist to manipulate the bytecode, and print the java method with elapsed time to logcat.

Getting Started

Configure this build.gradle like this:

buildscript {
    repositories {
        mavenLocal()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.5.0' // Or higher version
        classpath 'com.sdklite.trace:gradle-plugin:0.0.2' // HERE
    }
}

Then apply the trace plugin below the android plugin

apply plugin: 'com.sdklite.trace'

Finally, build your project and install the application to your android device, then you can filter the logcat like this:

adb logcat -s trace

Performance optimization

Trace gradle plugin is useful and convinient for performance optimization by dumping the trace log via logcat:

  1. Clean logcat

    adb logcat -c
  2. Launch app

  3. Dump trace log

    adb logcat -d -s trace | awk -F: '{print $NF}' | awk '{printf "%s, %s\n", $1, substr($2, 2)}'

    or filter by elapsed time

    adb logcat -d -s trace | awk -F: '{print $NF}' | awk '{et=strtonum(substr($2,2)); if (et > 30) { printf "%s, %s\n", $1, et}}'
com.sdklite.trace

SDKLite

SDKLite

Versions

Version
0.0.3
0.0.2
0.0.1