Rabbit is an Android APM framework that not only makes it easy for developers to monitor App performance locally, but also provides a complete data reporting system. The main functions currently included are as follows:

This article will provide a brief description of the rabbit’s capabilities, detailed usage documentation address: Usage documentation

Multi-graph warning ⚠️⚠️⚠️

Function is introduced

Application of speed

With compile-time code staking, Rabbit can easily count application cold startup times and page rendering times. Key time points of speed measurement statistics are defined as follows:

Application startup time statistics

After configuring the app home page, Rabbit can calculate the cold startup time as shown in the following figure:

Page rendering and network request time statistics

When combined with network request times, Rabbit calculates the total rendering time of a page. The full rendering time here is the time from the time the page is created to the time the page receives the request result and refreshes the page. The core idea is from the practice of Android automatic page speed measurement in Meituan. The final statistical page time is shown in the figure below:

Slow function detection

Based on compile-time code stubbing, Rabbit accurately counts the elapsed time of each function and filters out slower functions.

Slow functions are defined as functions that consume more time than a certain threshold in the main thread (Rabbit also supports configuration to detect slow functions in other threads).

Rabbit supports subcontracting detection slow functions:

Support to view the list of slow functions under each package and the stack of each slow function:

Code scanning

By providing Rabbit with a list of code scans,rabbit can scan at compile time for the location of those code calls. Blocking code is scanned by default, such as the following:

SharePreferences$Editor.commit()
Copy the code

The final scan results are displayed as follows:

Click the export button in the upper right corner to export the scan results to the SD card in json form.

Monitoring Network Logs

Rabbit can log network requests and easily view the returned JSON data:

Caton log monitoring

Rabbit uses Choreographer to detect the running of the main thread and asynchronously harvest the main thread stack to restore the scene of gridlock.

For the following code:

Thread.sleep(2000)
Copy the code

Rabbit gets the following Caton collection results:

FPS analysis

The rabbit calculates the main thread FPS while the main thread looper is running and displays it in real time:

Rabbit supports paging FPS:

Memory analysis

Function similar to FPS analysis, Rabbit supports real-time memory usage and paging analysis of memory usage:

Paging surface memory statistics:

Exception handling

By setting the Thread setDefaultUncaughtExceptionHandler, rabbit can capture the Java exception and display:

Memory leak capture

Rabbit integrates with LeakCanary 2.0.

Apk package analysis

Rabbit provides an executable JAR package that accurately analyzes large images, duplicate files, APK package size, and content composition in apK. The core ideas refer to Matrix APK package analysis.

Operation mode:

java -jar apk-analyzer.jar apk-analyzer-config.json
Copy the code

The apk-Analyzer-config. json command is used to configure the APK path to be analyzed and the location of the mapping file.

{
    "apkPath":"xxxx/app-Release.apk"."methodGroup": [{"name":"xxx"."package":"com.xxx.xx"}]."classMappingFilePath":"xxx/xxx.txt"."maxImageSizeKB"30} :Copy the code

The final analysis results are output to a JSON file:

apk-analyzer-result.json

{
    "AppInfo": {
        "versionCode": "1004000"."versionName": "1.4.0"."appSize": "21.51 MB"
    },
    "BigImageRes": [{"name": "assets/flutter_assets/images/icons/xxLogo.png"."size": "76.73 KB"}... . ] ."ApkCompose": [{"type": "so"."totalSizeStr": "8.05 MB"
        },
        {
            "type": "dex"."totalSizeStr": "6.54 MB"}... . ] ."DuplicatedFile": [{"files": [
                "res/drawable-xxhdpi-v4/bg_home_water_ripple.webp"."res/drawable-xxhdpi-v4/bg_keyboard_shadow_line.webp"]."fileSize": ""."md5Value": "d41d8cd98f00b204e9800998ecf8427e"}... ] ."MethodCount": {
        "total-count": 127732,
        "com.xxx.xx": 14800,
        "other-pkg": 112932}}Copy the code

APK analysis results are reported

You need to configure the reporting path in apk-Analyzer-config. json:

{
    "apkPath":"xxxx/app-Release.apk"."uploadPath":"xxxxxx/upload"
}
Copy the code

The data is guaranteed to be in the same format as the basic Rabbit data reporting format:

The data reported

Rabbit currently supports reporting most test data. Through some simple configuration, the detection data can be reported to the background. The basic format of rabbit data is as follows:

{
    "device_info_str": "{....}"."info_str": "{... }"."time": 1577775888933,
    "type": "fps_info"."use_time"19} :Copy the code
  • Type: indicates the type of the reported data
  • Device_info_str: device information, in the format of JSON character string
  • Info_str: Indicates the specific content of this type of data. The format is JSON string
  • Use_time: current application duration

Rabbit provides a report callback that makes it easy to implement custom report logic:

rabbitConfig.reportConfig.dataReportListener = object :RabbitReportConfig.DataReportListener{ override fun OnPrepareReportData (data: Any, currentUseTime: Long) {// Access your own reporting logic}}Copy the code

Custom panel

Rabbit provides UI extension apis that make it easy to put an application’s “back door” into Rabbit.

For details, see the Customize page in Rabbit

Availability versus configurability

Rabbit access is pretty simple, basically an init code:

Rabbit.init(rabbitConfig)
Copy the code

For details, see RabbitConfig.

For each function, Rabbit provides a rich configuration API and detailed usage documentation.

You can also easily control these functions in the Rabbit control panel:

Monitoring switch Setting

Quick function

Viewing the Current Configuration

It packages

Rabbit is not currently verified in an online environment and provides the NOOP package for easy access.

For details, see Importing noOP Packages

You can continue to use rabbit UI functionality in noOP packages

The code structure

Rabbit doesn’t use any particular architecture, but there is component isolation between functions in the form of modules:

Follow-up development plan

Improve existing features

Rabbit currently offers a fairly simple set of features, but will refine each feature to improve usability.

Performance measurement mode

Rabbit takes advantage of existing capabilities to do a global performance check and outputs a check score to evaluate the application’s performance. I’m still working on the implementation logic.

Management background

After completing the client function, we plan to build a performance monitoring background (two year late😬).

Contribute code

I am currently the only maintainer of Rabbit. One person can only do so much, so if you’re interested in Rabbit or feel like there’s something missing, feel free to comment! Welcome to add PR to rabbit development!

The last

Now that you’ve seen this, give the Rabbit ✨! Ollie give!

Personal public wechat account:

The resources

booster

matrix

DoraemonKit

ArgusAPM

fpsviewer

JsonViewer

AndroidPerformanceMonitor

.