- Notifications
You must be signed in to change notification settings - Fork5
MethodCanary is tool to record method invocations
License
NotificationsYou must be signed in to change notification settings
Kyson/MethodCanary
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
MethodCanary is tool to metric method cost.
Written forAndroidGodEye.
Root build.gradle
buildscript { repositories { jcenter() } dependencies { classpath'cn.hikyson.methodcanary:plugin:VERSION' }}Module com.android.application
applyplugin:'cn.hikyson.methodcanary.plugin'implementation'cn.hikyson.methodcanary:lib:VERSION'
cn.hikyson.methodcanary.plugin has some configurations.
AndroidGodEye { enableLifecycleTracer=true// Need lifecycle methods instrumentation, default true enableMethodTracer=true// Need common methods instrumentation, default true instrumentationRuleFilePath="app/AndroidGodEye-MethodCanary2.js"// Default AndroidGodEye-MethodCanary.js instrumentationRuleIncludeClassNamePrefix= ["cn/hikyson/methodcanary/sample"]// Default null }
Methods Meet this condition
instrumentationRuleFilePath && instrumentationRuleIncludeClassNamePrefixwill be instrumented
You can change instrumentation rule
- Add class prefix list to
instrumentationRuleIncludeClassNamePrefix - Put js file
AndroidGodEye-MethodCanary.jsin project root, content sample:
function isInclude(classInfo,methodInfo){ if(classInfo.name.startsWith('cn/hikyson/methodcanary/samplelib/R$') || classInfo.name === 'cn/hikyson/methodcanary/samplelib/BuildConfig' || classInfo.name === 'cn/hikyson/methodcanary/samplelib/R' || classInfo.name.startsWith('cn/hikyson/methodcanary/sample/R$') || classInfo.name === 'cn/hikyson/methodcanary/sample/BuildConfig' || classInfo.name === 'cn/hikyson/methodcanary/sample/R'){ return false } return true}- Can not change function name and desc:
function isInclude(classInfo,methodInfo) - Functions must return boolean type, default True for
isInclude - Param
classInfohas fields:int access,String name,String superName,String[] interfaces - Param
methodInfohas fields:int access,String name,String desc - Write
AndroidGodEye-MethodCanary.jsby javascript language
// start recordingMethodCanary.get().startMethodTracing("sessionName0")// stop recordingMethodCanary.get().stopMethodTracing("sessionName0",MethodCanaryConfig(5) ) {sessionTag,startMillis,stopMillis,methodEventMap ->Logger.d("finish!!!") }// Observe page lifecycle method costMethodCanary.get().addOnPageLifecycleEventCallback {lifecycleExitMethodEvent,page ->Logger.d(page.javaClass.simpleName +lifecycleExitMethodEvent) }MethodCanary.get().removeOnPageLifecycleEventCallback()
About
MethodCanary is tool to record method invocations
Topics
Resources
License
Code of conduct
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
No packages published