Fix a time calculation error in ctlstat_standard().
ctlstat.c: When converting a timeval to a floating point number in ctlstat_standard(), cast the nanoseconds calculation to a long double, so we don't lose precision. Without the cast, we wind up with a time in whole seconds only. Sponsored by: Spectra Logic MFC after: 3 days
This commit is contained in:
parent
7f15a8dff2
commit
ffc3b12c07
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=249334
@ -416,9 +416,10 @@ ctlstat_standard(struct ctlstat_context *ctx) {
|
|||||||
if (F_CPU(ctx) && (getcpu(&ctx->cur_cpu) != 0))
|
if (F_CPU(ctx) && (getcpu(&ctx->cur_cpu) != 0))
|
||||||
errx(1, "error returned from getcpu()");
|
errx(1, "error returned from getcpu()");
|
||||||
|
|
||||||
cur_secs = ctx->cur_time.tv_sec + (ctx->cur_time.tv_nsec / 1000000000);
|
cur_secs = ctx->cur_time.tv_sec +
|
||||||
|
((long double)ctx->cur_time.tv_nsec / 1000000000);
|
||||||
prev_secs = ctx->prev_time.tv_sec +
|
prev_secs = ctx->prev_time.tv_sec +
|
||||||
(ctx->prev_time.tv_nsec / 1000000000);
|
((long double)ctx->prev_time.tv_nsec / 1000000000);
|
||||||
|
|
||||||
etime = cur_secs - prev_secs;
|
etime = cur_secs - prev_secs;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user