Prior to the loop get the time. Initialize a shift register in the loop with that time. Now - at the end of the code in the while loop get the time once again, and find the difference between the value in the shift register and the new time. Wire the new time to the right hand shift register terminal...when you loop the difference will now tell how long each iteration takes.
In the attached example I have usied the get ms timer value to get the current time. The ms timer loops though so there is a possibility that it will give an incorrect value just when it resets...normally that's not a big problem, unless you want to do something critical based on the loop time...
In the example the loop code is just an add operation and a wait until next multiple (to
make the loop use some time), you can remove all that and put in your own code, or better - just add the timer code to your own loop.
PS. The example illustrates one thing about the wait next ms function that people sometimes overlook; the first time it is run it does not have a start value to relate to so it won't wait the specified number of ms on the first iteration.