ActivityFrameMetrics


Source link: https://github.com/frogermcs/ActivityFrameMetrics

ActivityFrameMetrics

Detect janky frames with Android Nougat FrameMetrics. This library won't work (yet) with any Android SDK lower than 24.

Article which describes this library and FrameMetrics can be found on my blog: [FrameMetrics?—?realtime app smoothness tracking] ( https://medium.com/@froger_mcs/framemetrics-realtime-app-smoothness-tracking-3d8550413c1c#.ba3ahfmbb)

FrameMetrics

Starting from Android SDK 24 (Nougat) there is a new API to monitor application UI performance. In older Android version we were be able to analyse data from last rendered 120 frames for each aby with adb shell command: adb shell dumpsys gfxinfo framestats displays. Now thanks you FrameMetrics this data is available directly from code and can be analysed in realtime.

More about FrameMetrics can be found in documentation and Android Nougat what's new section.

ActivityFrameMetrics

ActivityFrameMetrics is small 1-class library which prints janky frames warnings to Logcat for each Activity.

W/FrameMetrics: Janky frame detected on MainActivity with total duration: 23.13ms Layout/measure: 0.31ms, draw:0.95ms, gpuCommand:4.00ms others:17.87ms Janky frames: 22/638(3.4482758%) W/FrameMetrics: Janky frame detected on MainActivity with total duration: 25.02ms Layout/measure: 0.20ms, draw:0.44ms, gpuCommand:1.38ms others:23.01ms Janky frames: 23/768(2.9947915%) W/FrameMetrics: Janky frame detected on MainActivity with total duration: 24.46ms Layout/measure: 0.16ms, draw:0.28ms, gpuCommand:21.03ms others:3.00ms Janky frames: 24/770(3.116883%) E/FrameMetrics: Janky frame detected on MainActivity with total duration: 41.17ms Layout/measure: 0.25ms, draw:0.42ms, gpuCommand:2.10ms others:38.40ms Janky frames: 25/1268(1.9716088%) W/FrameMetrics: Janky frame detected on MainActivity with total duration: 17.66ms Layout/measure: 0.32ms, draw:0.32ms, gpuCommand:2.41ms others:14.62ms Janky frames: 26/1372(1.8950438%) E/FrameMetrics: Janky frame detected on MainActivity with total duration: 46.68ms Layout/measure: 0.33ms, draw:0.69ms, gpuCommand:2.51ms others:43.14ms Janky frames: 27/1378(1.9593613%)

Usage

Register ActivityFrameMetrics as an ActivityLifecycleCallback in your Application class.

public class MyApplication extends Application {

  @Override
  public void onCreate() {

super.onCreate();

registerActivityLifecycleCallbacks(new ActivityFrameMetrics.Builder().build());

  
}
 
}

By default library prints Logcat warning for every frame which was rendered longer than 17ms and error for these which was rendered longer than 34ms.

Default values (and others) can be changed with ActivityFrameMetrics.Builder params:

new ActivityFrameMetrics.Builder()

.warningLevelMs(20)
  //default: 17ms

.errorLevelMs(40)

 //default: 34ms

.showWarnings(true)
  //default: true

.showErrors(true)

 //default: true

.build();

Download

Java code

If you don't want to add another dependency to your project, just copy ActivityFrameMetrics.java to your source directory.

Library dependency

dependencies {

compile 'com.frogermcs.activityframemetrics:activityframemetrics:0.1.0' 
}

License

Copyright (C) 2016 Miroslaw Stanek  Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License. You may obtain a copy of the License at
  http://www.apache.org/licenses/LICENSE-2.0  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 

Resources

Traceur enables easier debugging of RxJava2 exceptions, by appending the source of any asynchronous calls to the original exception.

Lyra is a library that can save and restore the state of Android components easily through annotations. It will replace all the boilerplate code from onSaveInstanceState() to save and restore the state of your variables.

An user-friendly numerical input interface. It can easily be customized and is built to be used on Android-TV as well.

This library support nested scroll for refresh and load more, so you can use it with CoordinatorLayout and AppBarLayout and so no..

BackStack is a light weight android navigation library for view based navigation. It supports animations and multiple multipage containers like bottom bars and view pagers.

Custom Layout Manager for Recycler View which lays out its child views in circular or elliptical fashion

Scroll Wheel functionality implemented with Circular Relative Layout

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes