With this simple sketch that times one hundred thousand iterations of a loop:
int counter = 0;
long startmillis;
void setup() {
Serial.begin(115200);
startmillis = millis();
}
void loop() {
if ((counter++ % 100000) == 0) {
Serial.print("Time for 100000 iterations: ");
Serial.println(millis()-startmillis);
startmillis = millis();
}
}
Running at 80 Mhz that gives about 650, at 160Mhz 355. That number appears to slowly increase over time, not sure why that is or if it would stabilize somewhere if left running for a while. For comparison, i also tried that sketch on an Arduino Uno which gives 2735, so much slower.
long startmillis;
void setup() {
Serial.begin(115200);
startmillis = millis();
}
void loop() {
if ((counter++ % 100000) == 0) {
Serial.print("Time for 100000 iterations: ");
Serial.println(millis()-startmillis);
startmillis = millis();
}
}
[/code]
if the counter was reset to zero within the loop and the modulo replaced with a relational operator greater than maybe it would help.
Modulo base base ten of 100,000 is not the most economical calculation for a MCU to perform.