long elapsedTime = SystemClock.elapsedRealtime();
SystemClock.sleep(1000);
long startTime = SystemClock.elapsedRealtime(); // ...perform action to be measured... long endTime = SystemClock.elapsedRealtime(); long timeElapsed = endTime - startTime;This code measures the time taken to execute a specific action in milliseconds. The variables startTime and endTime hold the elapsed system time before and after the action execution respectively, and the variable timeElapsed holds the difference between them. The package library for android.os SystemClock is android.os.