Use this forum to chat about hardware specific topics for the ESP8266 (peripherals, memory, clocks, JTAG, programming)

User avatar
By torntrousers
#20707 I gave it a quick try with an ESP-12. Seems to work.
With this simple sketch that times one hundred thousand iterations of a loop:
Code: Select allint 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.
User avatar
By picstart
#20711 [code] 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();
}
}
[/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.