droid_dex
Introduction
Droid Dex is a powerful tool crafted to enhance the performance of your Android applications, ultimately elevating the user experience. With a focus on addressing key performance issues, it is your solution for addressing prevalent challenges like Jerky(Janky) Scrolling, Out of Memory errors (OOMs), High Battery Consumption, and instances of Application Not Responding (ANR).
A Flutter plugin for DroidDex โ Blinkitโs Android performance profiling library. This plugin bridges your Flutter app with native Kotlin performance signals using MethodChannel and EventChannel.
๐ Resources
๐ DroidDex GitHub Repository
๐ฐ Medium Article (Blinkit Engineering)
How Blinkit Cracked Android's Performance Puzzle with Droid Dex
Usage
In the pubspec.yaml of your flutter project, add the following dependency:
dependencies:
...
droid_dex: ^1.0.5
In your library add the following import:
import 'package:droid_dex/droid_dex.dart';
For help getting started with Flutter, view the online documentation.
It classifies and lets you analyze Android Device Performance across various parameters like:
| PARAMETER | DESCRIPTION |
|---|---|
CPU |
Total RAM, Core Count, CPU Frequency |
MEMORY |
Heap Limit, Heap Remaining, Available RAM |
NETWORK |
Bandwidth Strength, Download Speed, Signal Strength |
STORAGE |
Available Storage |
BATTERY |
Percentage Remaining, If Phone is Charging or Not |
into various levels: EXCELLENT, HIGH, AVERAGE, LOW
It is a compact library accompanied by extensive in-line documentation, providing users with the opportunity to delve into the code, comprehend each line thoroughly, and, ideally, contribute to its development.
Use Cases
- Consider a scenario where background polling of an API is necessary. In this context, the
BATTERYlevel becomes a crucial factor, as frequent polling can significantly drain the device's battery. To address this concern, you can optimize the process using the following code snippet:
DroidDex.getPerformanceLevelLd
([PerformanceClass.battery]).listen((performanceLevel) {
switch (performanceLevel) {
case PerformanceLevel.low:
// Implement image quality optimization
case PerformanceLevel.average:
// Implement image quality optimization
case PerformanceLevel.high:
// Implement image quality optimization
case PerformanceLevel.excellent:
// Implement image quality optimization
case null:
// Implement image quality optimization
case PerformanceLevel.unknown:
// Implement image quality optimization
}
})
-
Consider a scenario where you need to tailor the image quality for users based on their devices. In this context, the
NETWORKcondition plays a crucial role in decision-making, as achieving better image quality typically involves larger file sizes and increased data transfer. However,MEMORYis also a consideration, as higher-quality images generate heavier bitmaps, consuming more memory. To optimize this process, you can use the following code snippet:DroidDex.getWeightedPerformanceLevelLd({PerformanceClass.cpu : 2, PerformanceClass.memory to 1}).listen((performanceLevel){ switch (performanceLevel) { case PerformanceLevel.low: // Implement image quality optimization case PerformanceLevel.average: // Implement image quality optimization case PerformanceLevel.high: // Implement image quality optimization case PerformanceLevel.excellent: // Implement image quality optimization case null: // Implement image quality optimization case PerformanceLevel.unknown: // Implement image quality optimization } }
Usage
-
To get performance level for single/multiple parameters:
DroidDex.getPerformanceLevel(params)For observing the changes:
DroidDex.getPerformanceLevelLd(params).listen((performanceLevel){ switch (performanceLevel) { case PerformanceLevel.low: // Implement image quality optimization case PerformanceLevel.average: // Implement image quality optimization case PerformanceLevel.high: // Implement image quality optimization case PerformanceLevel.excellent: // Implement image quality optimization case null: // Implement image quality optimization case PerformanceLevel.unknown: // Implement image quality optimization } })Replace
paramswith list ofPerformance Class(es).Example:
var performanceLevel = await DroidDex.getPerformanceLevel([PerformanceClass.cpu, PerformanceClass.memory]) switch (performanceLevel) { case PerformanceLevel.low: // Implement image quality optimization case PerformanceLevel.average: // Implement image quality optimization case PerformanceLevel.high: // Implement image quality optimization case PerformanceLevel.excellent: // Implement image quality optimization case null: // Implement image quality optimization case PerformanceLevel.unknown: // Implement image quality optimization } -
To get performance level for multiple parameters with unequal weights:
DroidDex.getWeightedPerformanceLevel(params)For observing the changes:
DroidDex.getWeightedPerformanceLevelLd(params).listen((value){ switch (performanceLevel) { case PerformanceLevel.low: // Implement image quality optimization case PerformanceLevel.average: // Implement image quality optimization case PerformanceLevel.high: // Implement image quality optimization case PerformanceLevel.excellent: // Implement image quality optimization case null: // Implement image quality optimization case PerformanceLevel.unknown: // Implement image quality optimization } })Replace
paramswith a comma separated list ofPerformance Classesto theirWeights.Example:
DroidDex.getWeightedPerformanceLevelLd({PerformanceClass.cpu : 2, PerformanceClass.memory to 1}).listen((performanceLevel){ switch (performanceLevel) { case PerformanceLevel.low: // Implement image quality optimization case PerformanceLevel.average: // Implement image quality optimization case PerformanceLevel.high: // Implement image quality optimization case PerformanceLevel.excellent: // Implement image quality optimization case null: // Implement image quality optimization case PerformanceLevel.unknown: // Implement image quality optimization } })