examples/timer: fix time interval
authorChengchang Tang <tangchengchang@huawei.com>
Thu, 6 May 2021 09:29:36 +0000 (17:29 +0800)
committerThomas Monjalon <thomas@monjalon.net>
Wed, 12 May 2021 14:52:20 +0000 (16:52 +0200)
commit80aa15c4dff24e7a3b549f8dca37c16ae7220920
tree23bb8865391139a49078c2cec32d4b05ada0f94e
parentcc994d3922b7cd464d84fbef110dd65348e0a0da
examples/timer: fix time interval

Timer sample example assumes that the frequency of the timer is about
2Ghz to control the period of calling rte_timer_manage(). But this
assumption is easy to fail. For example. the frequency of tsc on ARM64
is much less than 2Ghz.

This patch uses the frequency of the current timer to calculate the
correct time interval to ensure consistent result on all platforms.

In addition, the rte_rdtsc() is replaced with the more recommended
rte_get_timer_cycles function in this patch.

Fixes: af75078fece3 ("first public release")
Cc: stable@dpdk.org
Signed-off-by: Chengchang Tang <tangchengchang@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
examples/timer/main.c