Accurate measurement of Arduino code execution time

It can be important in an Arduino UNO project, how much time is needed to execute some lines of code or a function. If you can measure the execution time accurately, you can optimize your code, speed up loops and you can be sure that the code, function or interrupt service routine can complete its job in time. Or you can just learn more about the code execution properties, compiler performance and you can see what you can expect from library functions.
Read the solution and download the accompanying example code.