Skip to content

cpu time off by a factor of 40x on M1 Macs #168

Open

Description

I believe ProcTime.Get is broken on M1 (and probably M2) Macs.
It does

	self.User = uint64(info.ptinfo.pti_total_user) / uint64(time.Millisecond)

but, on Darwin, pti_total_user needs to be scaled up by a factor of 125/3 because it is not expressed in nanos, but in "mach ticks" (I believe these ticks used to be nanos on Intel Macs). See https://developer.apple.com/documentation/driverkit/3433733-mach_timebase_info.

For reference, this is how htop does it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions