Best method to measure execution time in Android?

前端 未结 5 1756
臣服心动
臣服心动 2020-12-24 02:03

What is best method to measure execution time of Android code snippet?

I have a section of code before and after which I want to place timestamps to find out it\'s e

5条回答
  •  情话喂你
    2020-12-24 02:28

    I usually use System.nanoTime() for quick Measurement.

    A simple Setup like this

       val startTime =   System.nanoTime()
    
        //DO SOMETHING
    
       Log.e("Measure", TASK took : " +  ((System.nanoTime()-startTime)/1000000)+ "mS\n")
    

提交回复
热议问题