Giter Club home page Giter Club logo

androidgodeye's Introduction

AndroidGodEye


English README.md    中文 README_zh.md

Android developer lack of monitoring of performance data,especially in production environment. so we need "AndroidGodEye".

Overview

android_godeye_connect

AndroidGodEye is a performance monitor tool for Android(not limited to performance data) , you can easily monitor the performance of your app in real time in pc browser.

It is divided into 3 parts:

  1. Core provide all performance modules and produce performance datas.
  2. Debug Monitor provide a dashboard to show these performance datas.
  3. Toolbox make developers easy to use this library.

AndroidGodEye prodive several modules, such as cpu, heap, block, leak memory and so on.

Features

public static final String CPU = "CPU";                         // cpu info of device and app
public static final String BATTERY = "BATTERY";                 // battery info
public static final String FPS = "FPS";                         // fps info
public static final String LEAK = "LEAK";                       // detect memory leak
public static final String HEAP = "HEAP";                       // heap memory
public static final String PSS = "PSS";                         // pss
public static final String RAM = "RAM";                         // ram
public static final String NETWORK = "NETWORK";                 // network info
public static final String SM = "SM";                           // detect jam
public static final String STARTUP = "STARTUP";                 // startup metric
public static final String TRAFFIC = "TRAFFIC";                 // traffic of device and app
public static final String CRASH = "CRASH";                     // detect java、native crash and ANR
public static final String THREAD = "THREAD";                   // thread dump of app
public static final String PAGELOAD = "PAGELOAD";               // page(Activity and Fragment) lifecycle and load time metric
public static final String METHOD_CANARY = "METHOD_CANARY";     // methods time cost metric
public static final String APP_SIZE = "APP_SIZE";               // App size of apk code、storage and cache
public static final String VIEW_CANARY = "VIEW_CANARY";         // detect complex layout hierarchy and overdraw
public static final String IMAGE_CANARY = "IMAGE_CANARY";       // detect unreasonable memory use of image

Quickstart

Demo APK

Demo Project:https://github.com/Kyson/AndroidGodEyeDemo

Step1 Dependencies

Module Project build.gradle

dependencies {
  implementation 'cn.hikyson.godeye:godeye-core:VERSION_NAME'
  debugImplementation 'cn.hikyson.godeye:godeye-monitor:VERSION_NAME'
  releaseImplementation 'cn.hikyson.godeye:godeye-monitor-no-op:VERSION_NAME'
  implementation 'cn.hikyson.godeye:godeye-toolbox:VERSION_NAME'
}

Find VERSION_NAME in Github release

Root Project build.gradle

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath "cn.hikyson.methodcanary:plugin:PLUGIN_VERSION_NAME"
    }
}

Find PLUGIN_VERSION_NAME in MethodCanary github release

You need to config the logic of method canary injection, create js file:MethodCanary.js in project root dir, content like following:

/**
    classInfo
        {int access
         String name
         String superName
         String[] interfaces}

     methodInfo
         {int access
         String name
         String desc}
**/
function isExclude(classInfo,methodInfo){
    return false
}

function isInclude(classInfo,methodInfo){
    return classInfo.name.startsWith('cn/hikyson/godeyedemo'))
}

More configurations reference: MethodCanary

Module Project 'com.android.application' build.gradle

apply plugin: 'cn.hikyson.methodcanary.plugin'

Step2 Initialize And Install Modules

Init first in your application:

GodEye.instance().init(this);

Install modules in application onCreate, GodEye class is entrance for this step, all modules are provided by it.

if (ProcessUtils.isMainProcess(this)) {//install in main process
    GodEye.instance().install(GodEyeConfig.fromAssets("<config path>"));
}

"<config path>" is assets path of config, content reference: install.config

Optional Uninstall Modules

Uninstall modules when you don't need it(not recommend):

GodEye.instance().uninstall();

Note that network and startup module don't need install and uninstall.

When install finished, GodEye begin produce performance data, generally you can call consume of modules to get these datas, for example:

GodEye.instance().<Cpu>getModule(GodEye.ModuleName.CPU).subject().subscribe()

Just like we will mention later,Debug Monitor is one of these consumers.

Step3 Install Performance Visualization Dashboard

GodEyeMonitor class is entrance for this step.

Start performance visualization dashboard:

GodEyeMonitor.work(context)

Stop it:

GodEyeMonitor.shutDown()

Install IDE Plugin

Install Android Studio plug-in(Search AndroidGodEye in Android Studio plugin setting),Then you can find AndroidGodEye in main toolbar,click it and it will open dashboard in browser.

https://github.com/Kyson/AndroidGodEye/blob/master/ART/android-godeye-plugin-position.png

Connect mobile phones and computers with USB, run adb forward tcp:5390 tcp:5390, then open http://localhost:port/index.html(Note that /index.html is necessary!!!) on PC. If you don't have a USB, you can also open http://mobile ip:port/index.html directly, ensure that mobile phones and PC are in the same LAN segment of course.

Default port is 5390, you can find ip in logcat output after call GodEyeMonitor.work(context,port), log is like:'Open AndroidGodEye dashboard [ http://ip:port/index.html" ] in your browser...'.

Now enjoy it!

Performance Visualization Dashboard

Click ↓ to preview

MethodCanary

android_god_eye_dashboard1

Fps/RAM/PSS/Battery...

android_god_eye_dashboard2

Cpu/Heap/Traffic...

android_god_eye_dashboard3

Leak Memory/App Jank(Block)

android_god_eye_dashboard4

Leak Memory GIF

android_god_eye_leak

Jank(Block) GIF

android_god_eye_block

Page Lifecycle(Page Load)/Network

android_god_eye_dashboard5

Page Lifecycle(Page Load) GIF

android_god_eye_pageload

Network GIF

android_god_eye_network

Network Detail

android_god_eye_dashboard6

Thread

android_god_eye_dashboard7

Framework

How does AndroidGodEye work?As below:

android_god_eye_framework_2

License

AndroidGodEye is under Apache2.0.

Contributors

About Me

androidgodeye's People

Contributors

kyson avatar imgbotapp avatar codacy-badger avatar ahhbzyz avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.