-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Correct the ClocksPerSec scaling factor on Darwin #846
Conversation
Change the definition of ClocksPerSec to read from limits.h
collector/cpu_darwin.go
Outdated
@@ -45,7 +46,7 @@ import ( | |||
import "C" | |||
|
|||
// ClocksPerSec default value. from time.h | |||
const ClocksPerSec = float64(128) | |||
const ClocksPerSec = C.CLK_TCK |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want to keep the float64() cast to avoid integer math.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, ack.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
The circleci build failure is due to Go 1.10 not being in the Circle 1.0 machine. Plus it doesn't test Darwin anyway. I tested this patch locally, looks good. |
* Update cpu_darwin.go Change the definition of ClocksPerSec to read from limits.h * Update cpu_darwin.go
Change the definition of ClocksPerSec to read from limits.h
Per #845, CPU counters are scaled by an incorrect factor (128 was assumed, which is the FreeBSD default [?]). Correct value on Darwin is given by the C macro CLK_TCK in limits.h