void setup() {
Serial.begin(115200);
Serial.println(" ");
}
void loop() {
//cycletime();
// return;
static unsigned long cycles = 0;
static unsigned long elapse = 0;
static unsigned long window = millis();
unsigned long test = micros();
//PROGRAMM-------
// delay(1000);
cycles++;
elapse += (micros() - test);
if (millis() - window > 10000) {
window = millis();
Serial.println("ELAPSE: " + String(elapse) + "µs");
Serial.println("CYCLES: " + String(cycles));
double average = (double)elapse / (double)cycles;
Serial.println("AVERAGE: " + String(average) + " µs/cycle");
Serial.println();
elapse = 0;
cycles = 0;
}
}
void cycletime() {
static unsigned long cycles = 0;
static unsigned long elapse = 0;
static unsigned long window = millis();
static unsigned long test = micros();
//PROGRAMM-------
//delay(1000);
cycles++;
elapse += (micros() - test);
if (millis() - window > 10000) {
window = millis();
Serial.println("ELAPSE: " + String(elapse) + "µs");
Serial.println("CYCLES: " + String(cycles));
double average = (double)elapse / (double)cycles;
Serial.println("AVERAGE: " + String(average) + " µs/cycle");
Serial.println();
elapse = 0;
cycles = 0;
}
test = micros();
}