Measuring how Xposed modules affect device performance.
- Scoped modules (target single app) β minimal impact
- System-wide modules β higher overhead, especially with hooks in frequently-called methods
- Callback count β each hook/callback adds latency
# View Xposed module load time
adb shell dumpsys | grep -i xposed
# Check Zygisk timing
adb logcat | grep -i "zygisk\|lsposed"- Open Android Studio β Profiler
- Select device and process
- Monitor CPU, memory during app launch
- Compare with modules enabled vs disabled
Java.perform(function() {
var start = Java.use("java.lang.System").nanoTime();
// Your hook
var target = Java.use("com.example.Class");
target.method.implementation = function() {
console.log("[Perf] Method called");
return this.method.call(this);
};
var elapsed = (Java.use("java.lang.System").nanoTime() - start) / 1000000;
console.log("[Perf] Hook setup took: " + elapsed + "ms");
});- β Scope module to specific apps if possible
- β Avoid hooking frequently-called methods (onCreate, onDraw, etc.)
- β Use reflection sparingly β cache references
- β Test on low-end devices (if targeting them)
- β Monitor battery impact (logcat + Battery Historian)
- β Profile memory leaks (if holding references)
- Clipboard monitors β +2-5% CPU
- Animation tweaks β +1-3% depending on hook depth
- Permission overrides β minimal if scoped
- Inline encryption logging β +5-15% for crypto ops
β Avoid:
onCreate,onResume,onDraw(called frequently)View.inflate,ThreadconstructorsSystem.loadLibrary(affects startup)
β Better:
- Lifecycle callbacks (
onStart,onPause) - Specific UI update methods
- User-triggered methods
adb shell perfetto -c perfetto_config.pb -o /tmp/trace.pb
# Analyze in Perfetto UI: https://ui.perfetto.dev