MCPcopy Create free account
hub / github.com/F-Stack/f-stack / timer_sanity_check

Function timer_sanity_check

dpdk/app/test/test_timer.c:493–528  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

491}
492
493static int
494timer_sanity_check(void)
495{
496#ifdef RTE_LIBEAL_USE_HPET
497 if (eal_timer_source != EAL_TIMER_HPET) {
498 printf("Not using HPET, can't sanity check timer sources\n");
499 return 0;
500 }
501
502 const uint64_t t_hz = rte_get_tsc_hz();
503 const uint64_t h_hz = rte_get_hpet_hz();
504 printf("Hertz values: TSC = %"PRIu64", HPET = %"PRIu64"\n", t_hz, h_hz);
505
506 const uint64_t tsc_start = rte_get_tsc_cycles();
507 const uint64_t hpet_start = rte_get_hpet_cycles();
508 rte_delay_ms(100); /* delay 1/10 second */
509 const uint64_t tsc_end = rte_get_tsc_cycles();
510 const uint64_t hpet_end = rte_get_hpet_cycles();
511 printf("Measured cycles: TSC = %"PRIu64", HPET = %"PRIu64"\n",
512 tsc_end-tsc_start, hpet_end-hpet_start);
513
514 const double tsc_time = (double)(tsc_end - tsc_start)/t_hz;
515 const double hpet_time = (double)(hpet_end - hpet_start)/h_hz;
516 /* get the percentage that the times differ by */
517 const double time_diff = fabs(tsc_time - hpet_time)*100/tsc_time;
518 printf("Measured time: TSC = %.4f, HPET = %.4f\n", tsc_time, hpet_time);
519
520 printf("Elapsed time measured by TSC and HPET differ by %f%%\n",
521 time_diff);
522 if (time_diff > 0.1) {
523 printf("Error times differ by >0.1%%");
524 return -1;
525 }
526#endif
527 return 0;
528}
529
530static int
531test_timer(void)

Callers 1

test_timerFunction · 0.85

Calls 6

rte_get_tsc_hzFunction · 0.85
rte_get_hpet_hzFunction · 0.85
rte_get_hpet_cyclesFunction · 0.85
rte_delay_msFunction · 0.85
printfFunction · 0.50
rte_get_tsc_cyclesFunction · 0.50

Tested by

no test coverage detected