Execute a Serial.print(""); ~4uS PLUS ~1.04mS per character printed (example; Serial.print("hello"); 5 characters so it takes ~5.204mS. NOTE: same timing regardless of baud-rate
Execute math functions; examples; INT =+ 1, VAR = sqrt(VAR), cos(), sin(), tan(); no perceptible time change
Pretty basic stuff and if anyone is interested in a more advanced functionality/sequence I'd be happy to test for you!
Please post the program you used to produce your results and explain how you use the 'scope to do the measurementsI would be interested to see the results for digitalWriteFast() and digitalReadFast() from the digitalWriteFast library...R
Here is one way to measure code timing:
Indeed. But how did the OP do it ?...R
These are taken with TekTronix TDS 2024C Oscilloscope, I used a digitalWrite (pin, HIGH); digitalWrite (pin, LOW);
I'd prefer to see the OP's program and his/her own description of the timing process....R
Also; what do you mean by "fighting the optimiser" give me a math function to test and I'll be happy to see the effect...
volatile int myVal;
If the compiler sees that the result of a calculation is never used it just leaves the calculation out of the code.
Execute math functions; examples; INT =+ 1, VAR = sqrt(VAR), cos(), sin(), tan(); ~250nS
Four cycles at 16MHz?Dream on
What am I doing wrong?