projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
cpusleep plugin: calculating in integers
[collectd.git]
/
src
/
cpusleep.c
diff --git
a/src/cpusleep.c
b/src/cpusleep.c
index
9a0e17e
..
4d3547a
100644
(file)
--- a/
src/cpusleep.c
+++ b/
src/cpusleep.c
@@
-71,7
+71,9
@@
static int cpusleep_read(void)
// to avoid false positives in counter overflow due to reboot,
// derive is used. Sleep is calculated in milliseconds
// to avoid false positives in counter overflow due to reboot,
// derive is used. Sleep is calculated in milliseconds
- derive_t sleep = (derive_t) ((b.tv_sec - m.tv_sec)*1e3 + (b.tv_nsec - m.tv_nsec)*1e-6);
+ derive_t diffsec = b.tv_sec - m.tv_sec;
+ derive_t diffnsec = b.tv_nsec - m.tv_nsec;
+ derive_t sleep = diffsec * 1000 + diffnsec / 1000000;
cpusleep_submit(sleep);
cpusleep_submit(sleep);