hammerspoon2-docs
    Preparing search index...

    Function cpuUsage

    • Measures how busy the CPU is, across all of its cores, over an interval.

      macOS only reports how much CPU time has been spent since the Mac started, so this takes one reading now and another after seconds, and reports how the time in between was spent. Nothing blocks while it waits. Shorter intervals react faster but are noisier.

      Parameters

      • Optionalseconds: number

        How long to measure for, in seconds, up to an hour (3600). Defaults to 1.

      Returns Promise<HSCPUUsage>

      A Promise that resolves with the CPU usage over the interval, or rejects with an EINVALIDARG error if seconds isn't a positive number no larger than 3600