diff --git a/README.md b/README.md index dddd760..5da6ed1 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,61 @@ -# TraceTools -perfetto trace tools for android +# # TraceTools +MTrace is an Android dynamic ATrace tool that utilizes ART method hooks. Work with [Perfetto](https://perfetto.dev/docs/), which allows you to collect system-wide performance traces from Android devices from a variety of data sources (kernel scheduler via ftrace, userspace instrumentation via atrace and all other data sources listed in this site). + + +### Getting Started +#### Installation Via Maven +Add the following lines to build.gradle on your app module: +``` +dependencies { + implementation 'io.gitee.joychic:TraceTools:0.0.1' + // replace "0.0.1" with any available version +} +``` + +### Quick Tutorial + +Setup MTrace on App startup, say your Application class, add these lines: + +``` + override fun onCreate() { + super.onCreate() + MTrace.start( + MTrace.ConfigBuilder() + .isDebug(false) + .setMethodName("com.joychic.trace") + .build() + ) + } +``` + +#### [Download record_android_trace](https://perfetto.dev/docs/quickstart/android-tracing) + +On Linux and Mac: +``` +curl -O https://raw.githubusercontent.com/google/perfetto/main/tools/record_android_trace +``` +then, chmod record_android_trace +> chmod u+x record_android_trace + +you can also add alias to your `.bashrc` or `.zshrc` + +``` +alias perfetto='${ANDROID_HOME}/record_android_trace -o trace_file.perfetto-trace -t 20s -b 1024mb gfx input view webview wm am sm audio video camera dalvik rs bionic sched freq idle disk load sync binder_lock' +``` + +On Windows: +``` +curl -O https://raw.githubusercontent.com/google/perfetto/main/tools/record_android_trace +``` + + +#### Recording a trace +``` + perfetto -a com.joychic.trace +``` +replace `com.joychic.trace` with your application + +when finished, press `Control+C` `https://ui.perfetto.dev/#!/record/cpu` + +### Performance +![](doc/17231951542551.jpg) \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index ce826f2..8fe1896 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -52,7 +52,5 @@ dependencies { androidTestImplementation 'androidx.test.ext:junit:1.2.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1' - -// implementation 'io.gitee.joychic:TraceTools:0.0.1' implementation(project(":trace")) } \ No newline at end of file diff --git a/app/src/main/java/com/joychic/trace/App.kt b/app/src/main/java/com/joychic/trace/App.kt index 807054b..79b4d8f 100644 --- a/app/src/main/java/com/joychic/trace/App.kt +++ b/app/src/main/java/com/joychic/trace/App.kt @@ -7,8 +7,8 @@ class App : Application() { super.onCreate() MTrace.start( MTrace.ConfigBuilder() - .isDebug(true) - .setMethodName("com.joychic.trace") + .isDebug(false) + .setMethodName(packageName) .build() ) } diff --git a/doc/17231951542551.jpg b/doc/17231951542551.jpg new file mode 100644 index 0000000..dbd9bbd Binary files /dev/null and b/doc/17231951542551.jpg differ