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

Function get_tsc_freq

dpdk/lib/eal/windows/eal_timer.c:51–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49}
50
51uint64_t
52get_tsc_freq(void)
53{
54 LARGE_INTEGER t_start, t_end, elapsed_us;
55 LARGE_INTEGER frequency;
56 uint64_t tsc_hz;
57 uint64_t end, start;
58
59 QueryPerformanceFrequency(&frequency);
60
61 QueryPerformanceCounter(&t_start);
62 start = rte_get_tsc_cycles();
63
64 rte_delay_us_sleep(US_PER_SEC / 10); /* 1/10 second */
65
66 if (rte_errno != 0)
67 return 0;
68
69 QueryPerformanceCounter(&t_end);
70 end = rte_get_tsc_cycles();
71
72 elapsed_us.QuadPart = t_end.QuadPart - t_start.QuadPart;
73
74 /*
75 * To guard against loss-of-precision, convert to microseconds
76 * *before* dividing by ticks-per-second.
77 */
78 elapsed_us.QuadPart *= US_PER_SEC;
79 elapsed_us.QuadPart /= frequency.QuadPart;
80
81 double secs = ((double)elapsed_us.QuadPart)/US_PER_SEC;
82 tsc_hz = (uint64_t)((end - start)/secs);
83
84 /* Round up to 10Mhz. 1E7 ~ 10Mhz */
85 return RTE_ALIGN_MUL_NEAR(tsc_hz, CYC_PER_10MHZ);
86}
87
88
89int

Callers

nothing calls this directly

Calls 2

rte_delay_us_sleepFunction · 0.70
rte_get_tsc_cyclesFunction · 0.50

Tested by

no test coverage detected