app-resource-profiler
v1.0.1
Published
Real-time Android resource monitoring tool (CPU, Memory, Network) with web dashboard
Maintainers
Readme
Android Resource Profiler
A powerful, real-time Android resource monitoring tool that tracks CPU, Memory, Network, Battery, and Graphics metrics. It provides both a programmatic API for automation (e.g., CI/CD pipelines) and a live web dashboard for real-time visual analysis.
Features
- Real-time Monitoring: comprehensive metrics including CPU usage, Memory (PSS), Network throughput, Battery status, and Frame stats.
- Live Dashboard: Visualize metrics in real-time via a web interface.
- Agent-less: Works entirely over ADB; no root access or on-device agent required.
- Programmatic API: Easy integration into Node.js scripts and automation frameworks.
- Report Generation: Generate summary reports and visual graphs (PNG).
- TypeScript Support: Fully typed for better developer experience.
Installation
npm install app-resource-profilerPrerequisites
- ADB (Android Debug Bridge) must be installed and available in your system PATH.
- Node.js >= 14
- An Android device connected via USB or TCP/IP.
CLI Usage
You can use the tool directly from the command line to start a live dashboard session.
npx app-resource-profiler <package-name> [options]Options
| Option | Description | Default |
|--------|-------------|---------|
| --port <number> | Port to run the dashboard on | 3000 |
| --interval <ms> | Polling interval in milliseconds | 1000 |
| --duration <ms> | Duration to run in milliseconds (optional, runs indefinitely if omitted) | undefined |
| --help, -h | Show help message | |
Example
Monitor the package com.example.app on port 8080:
npx app-resource-profiler com.example.app --port 8080Open http://localhost:8080 in your browser to view the metrics.
Programmatic Usage
Integrate the profiler into your automation or testing scripts.
Basic Monitoring
import { ResourceMonitor } from 'app-resource-profiler';
const monitor = new ResourceMonitor({
packageName: 'com.example.app',
pollIntervalMs: 1000,
});
monitor.on('snapshot', (data) => {
console.log(`CPU: ${data.cpu.usagePercent}% | MEM: ${data.memory.pssTotal}KB`);
});
await monitor.start();
// ... run your tests ...
const report = await monitor.stop();
console.log('Average CPU:', report.summary.averageCpu);Live Server Integration
import { ResourceMonitor, LiveDashboardServer } from 'app-resource-profiler';
const server = new LiveDashboardServer(3000);
server.start();
const monitor = new ResourceMonitor({ packageName: 'com.example.app' });
monitor.on('snapshot', (data) => {
server.broadcast(data); // Send data to connected web clients
});
await monitor.start();Generating Visual Reports
You can generate a visual report (image) of the monitoring session.
import { ResourceMonitor, ScreenshotReporter } from 'app-resource-profiler';
// ... run monitor ...
const report = await monitor.stop();
const reporter = new ScreenshotReporter();
await reporter.generate(report, 'performance-report.png');License
ISC
