I'm trying to measure the execution time of different functions, and I'm using serial print. However, I noticed the function printing several times per loop iteration, rather than only once. I would be grateful for any help to try to understand why.
@guix and @Juraj thank you for the insight. I'll test this later today! Would you say this is the "best" way to measure execution time of a function?
edit: so if it's not printing several times per loop, then is it looping through several times per print? I just don't get why it looks like it prints several times per iteration. If it's not fast enough, wouldn't that mean it would print old data, but with new timestamps each time? What's confusing is the timestamps make it seem that several prints are happening at the same time stamp, even though the function is called only once per loop.
Thank you for the input, I'm being a bit daft here (sorry!) but I still don't get why it's printing it several times instead of just once? I can understand from your explanation why the data would be the same, but why would it print it several times instead of just once?
I'm just saying that the timestamps shown in the Serial monitor is not very accurate, it does not show the exact time when the message was received. It's not updated every millisecond
If you are still not convinced, just print the value of millis(), you will see that each line is unique