框架代码里timer的(也许算是)bug #197
Ayana-chan
started this conversation in
General
Replies: 1 comment
-
这样写会减少损失(但会更容易溢出) /// get current time in milliseconds
time::read() * MSEC_PER_SEC / (CLOCK_FREQ )
/// get current time in microseconds
time::read() * MICRO_PER_SEC / (CLOCK_FREQ ) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
一旦代码里面(如taskinfo)混用
get_time_ms
和get_time_us
就会出问题!因为时间计算是先获得时间再除以(CLOCK_FREQ / xxxx_PER_SEC)
;但是,(CLOCK_FREQ / MICRO_PER_SE)
会损失很大的精度:12_500_000 / 1_000_000 = 12
,导致get_time_us
结果偏大Beta Was this translation helpful? Give feedback.
All reactions