mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
tests: improve calculation in hwtimer_wait
Kudos to @Kijewski
This commit is contained in:
parent
741536a82d
commit
31391622a3
@ -33,20 +33,10 @@ int main(void)
|
||||
puts("This is a regression test for a race condition in hwtimer_wait.");
|
||||
puts("When the race condition is hit, the timer will wait for a very very long time.");
|
||||
|
||||
int iterations = 10000;
|
||||
/* `#define I_CHANGED_START_DURATION 1` or update the constant if
|
||||
* you change start_duration */
|
||||
int start_duration = 256;
|
||||
long iterations = 10000;
|
||||
long start_duration = 256;
|
||||
long duration = iterations * start_duration * 2L;
|
||||
|
||||
long duration = iterations * (
|
||||
/* geometric series */
|
||||
#if I_CHANGED_START_DURATION
|
||||
(1 - pow(2,(log2(start_duration) + 1)))
|
||||
/ (1 - 2)
|
||||
#else
|
||||
511.0
|
||||
#endif
|
||||
);
|
||||
printf("The test should take about %li sec.\n", (HWTIMER_TICKS_TO_US(duration)/1000000));
|
||||
|
||||
for (unsigned long r = iterations; r > 0; r--) {
|
||||
|
Loading…
Reference in New Issue
Block a user