Best method to measure execution time in Android?

前端 未结 5 1775
臣服心动
臣服心动 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:21

    Kotlin Developers

    To get the elapsed time in MilliSeconds:

    val elapsedTime= measureTimeMillis {
                // call you method from here or add any other statements
    } 
    

    To get the time in NanoSeconds:

    val elapsedTime= measureNanoTime {
                // call you method from here or add any other statements
    }
    

提交回复
热议问题