当前位置: 代码迷 >> Android >> 使用AspectJ的Android方法执行时间
  详细解决方案

使用AspectJ的Android方法执行时间

热度:87   发布时间:2023-08-04 11:13:04.0

我的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。 这是正确的还是我做错了什么?

System.currentTimeMillis()返回一个long,但是您将其插入到double中。 我会尝试将其更改为很长的时间,看看是否能解决问题。

  相关解决方案