manitou
Senior Member+
I just got my Teensy 3.0, tried some simple UNO programs. The little fibonacci benchmarks ran, but
it reported 0 ms for times?? (I know it's not taking 0 ms). is there some magic for millis()?
micros() reports good timings
Here is the UNO sketch.
it reported 0 ms for times?? (I know it's not taking 0 ms). is there some magic for millis()?
micros() reports good timings
Here is the UNO sketch.
Code:
unsigned long fibo (unsigned int n) {
if (n < 2) {
return (n);
}
else {
return fibo(n - 1) + fibo(n - 2);
}
}
void setup() {
Serial.begin(9600);
}
void loop() {
int n;
long result;
long startTime;
long endTime;
long ms;
for (n = 0; n <= 26; n++) {
Serial.print("fibo- ");
Serial.print(n);
startTime = millis();
result = fibo(n);
endTime = millis();
ms = (endTime - startTime);
Serial.print(" "); Serial.print(result);
Serial.print(" "); Serial.println(ms);
}
delay(2000);
}
Last edited: