diff --git a/samples/sim65/timer_example.c b/samples/sim65/timer_example.c index 0675979b1..8262bdff8 100644 --- a/samples/sim65/timer_example.c +++ b/samples/sim65/timer_example.c @@ -41,7 +41,6 @@ */ #include -#include #include static uint32_t timestamp(void) @@ -67,9 +66,9 @@ int main(void) { unsigned max_term; unsigned long result; - uint32_t t1, t2, overhead, duration; - int32_t d0, d1; - int32_t predicted_duration; + uint32_t t1, t2, overhead; + int32_t d0, d1, duration; + int32_t predicted_duration; /* Calibration measurement of zero clock cycles, to determine the overhead. */ @@ -101,9 +100,11 @@ int main(void) max_term = 10000; predicted_duration = d0 + max_term * (d1 - d0); - printf("predicted duration for max_term = %u: %lu\n", max_term, predicted_duration); + printf("predicted duration for max_term = %u: %ld\n", max_term, predicted_duration); - /* Do the actual measurement for max_term = 10000. */ + /* Do the actual measurement for max_term = 10000. + * Note: equality between the prediction and the measurement is only achieved if we compile with -O. + */ t1 = timestamp(); result = calc_sum_terms(max_term); @@ -111,7 +112,6 @@ int main(void) duration = (t2 - t1) - overhead; printf("max_term = %u -> result = %lu; duration = %ld\n", max_term, result, duration); - /* Report success or failure. */ - return (duration == predicted_duration) ? EXIT_SUCCESS : EXIT_FAILURE; + return 0; }