Have a look at the code! Its open source so you have it all, and the top-level code
is in main.cpp:
int main(void)
{
init();
#if defined(USBCON)
USBDevice.attach();
#endif
setup();
for (;;) {
loop();
if (serialEventRun) serialEventRun();
}
return 0;
}
So the loop that calls loop() also checks for serial events. Note that what's not
shown here is the hidden initialization of all static C++ instances which have
their constructors called before main runs (and before any of the hardware
is initialized - thus you may not call any UI functions in constructors, just
initialize instance variables.)
Why not create your own sub-function that sets and calls the led and run it inside your for() loop? That should answer any questions. There might also be some variable initialization as part of starting loop() depending on how many local variables you create and initialize.
Since your code is pseudo-code it is hard to say exactly.
Thanks MarkT. This explains it. In my case I have my own serial so doing my own loop should be fine. Possibly additional speed improvement is due to better variable caching across loop iterations.