I know there are various memory available routines going around, but I wondered if anyone has come up with a way to measure the main loop time.
We used to have it on our Z80 (Z280) based Cpu's years ago and it measured & displayed the main loop in uS......very handy for seeing what was going on.
Managed this via a counter in my main loop, then every 40mS (my interrupt loop) measuring how many main loop counts occurred and then translated that into mS.
That sounds an awful lot - I assume your serial print time is included in that?
[edit]Fairly empty "loop", like CodingBadly's gives about 8.18us, averaged over 1000 loops[/edit]
Not using serial print at all.......my project has an 4*20 LCD, ethernet shield (web server), servo drive, analogue inputs, digital I/O etc.......550 lines of code.
Using a bunch of other libraries as well, including eeprom.h, pgmspace.h.
This is why I wanted to measure the main loop time.
It's my first Arduino project and I wanted to push it to the limit to see what's capable and what's not. I'm already at the limit of sram.
I guess my next test will be to write a simple sketch with everything ripped out and measure the loop time at it's fastest.
That sounds an awful lot - I assume your serial print time is
included in that? Fairly empty "loop", like CodingBadly's gives
about 8.18us, averaged over 1000 loops
I agree 0.77mS is a lot, so I moved some code from my main loop to my 40mS interrupt loop and immediately it's down to 0.07mS (70uS).
It was moving the analogRead's that gained the speed. I didn't know they were that slow.
Does that involve serial communication? Mine does.