@@ -344,20 +344,34 @@ void ticker_increment_test(void)
344
344
} else { // high frequency tickers
345
345
346
346
uint32_t num_of_cycles = NUM_OF_CYCLES;
347
+ const uint32_t repeat_count = 20 ;
348
+ const uint32_t max_inc_val = 100 ;
347
349
348
350
uint32_t base_tick_count = count_ticks (num_of_cycles, 1 );
349
351
uint32_t next_tick_count = base_tick_count;
350
352
uint32_t inc_val = 0 ;
353
+ uint32_t repeat_cnt = 0 ;
351
354
352
- while (inc_val < 100 ) {
353
-
355
+ while (inc_val < max_inc_val) {
354
356
next_tick_count = count_ticks (num_of_cycles + inc_val, 1 );
355
357
356
358
if (next_tick_count == base_tick_count) {
357
359
358
- /* Same tick count, so increase num of cycles. */
359
- inc_val++;
360
+ /* Same tick count, so repeat 20 times and than
361
+ * increase num of cycles by 1.
362
+ */
363
+ if (repeat_cnt == repeat_count) {
364
+ inc_val++;
365
+ repeat_cnt = 0 ;
366
+ }
367
+
368
+ repeat_cnt++;
360
369
} else {
370
+ /* Check if we got 1 tick diff. */
371
+ if (next_tick_count - base_tick_count == 1 ||
372
+ base_tick_count - next_tick_count == 1 ) {
373
+ break ;
374
+ }
361
375
362
376
/* It is possible that the difference between base and next
363
377
* tick count on some platforms is greater that 1, in this case we need
@@ -366,12 +380,8 @@ void ticker_increment_test(void)
366
380
*/
367
381
num_of_cycles /= 2 ;
368
382
inc_val = 0 ;
383
+ repeat_cnt = 0 ;
369
384
base_tick_count = count_ticks (num_of_cycles, 1 );
370
-
371
- if (next_tick_count - base_tick_count == 1 ||
372
- base_tick_count - next_tick_count == 1 ) {
373
- break ;
374
- }
375
385
}
376
386
}
377
387
0 commit comments