问题描述
我的Android代码有几种方法,我正在使用AspectJ在Android中找到每种方法的执行时间。 为此,我正在使用-
pointcut methodCalls():
execution(* com.example.buttontestaspect..*(..))&& !within(com.example.buttontestaspect.testbutton);
before(): methodCalls(){
start = System.currentTimeMillis();//Start of execution time of method
Log.d("hi", "start = " + start);
}
after(): methodCalls(){
double end = System.currentTimeMillis();//End of execution time of method
Log.d("hi", "end = " + end);
double t = (end - start);
}
每当开始执行新方法时,我都会在before()中检查开始时间的值。 它始终是常数,等于1.445714916545E12。 这是正确的还是我做错了什么?
1楼
System.currentTimeMillis()返回一个long,但是您将其插入到double中。 我会尝试将其更改为很长的时间,看看是否能解决问题。