Displaying Execution time of code

How to display the total execution time of any arduino code? what should be the code for this purpose?

Basic method

unsigned long startTime = micros();
// your code
unsigned long endTime = micros();
unsigned long duration = endTime - startTime;
Serial print ("That code took ");
Serial.println(" microseconds to execute.");