darwin: Fetch CPU frequency via sysctl (hw.cpufrequency) - #2091
Conversation
Signed-off-by: badger200 <badger200@users.noreply.github.com> Assisted-by: Antigravity <ai@google.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughDarwin CPU sampling now includes the sysctl API and reads Suggested reviewers: Poem
Merge Risk: ⚪ Minimal · up to This localized Darwin change enables CPU-frequency display through read-only system metadata lookup without changing interfaces, permissions, persistent state, or deployment behavior. No actionable merge-blocking risk remains beyond normal checks and review. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| size_t len = sizeof(cpufreq); | ||
| if (sysctlbyname("hw.cpufrequency", &cpufreq, &len, NULL, 0) == 0 && cpufreq > 0) { | ||
| frequency = (double)cpufreq / 1E6; | ||
| } else if (sysctlbyname("hw.cpufrequency_max", &cpufreq, &len, NULL, 0) == 0 && cpufreq > 0) { |
There was a problem hiding this comment.
is len guaranteed to be unchanged when the first of these two sysctls fails?
| if (mtr->host->settings->showCPUFrequency) { | ||
| uint64_t cpufreq = 0; | ||
| size_t len = sizeof(cpufreq); | ||
| if (sysctlbyname("hw.cpufrequency", &cpufreq, &len, NULL, 0) == 0 && cpufreq > 0) { |
There was a problem hiding this comment.
Is this the per-core frequency? Because I don't see, where it follow's up on the cpu argument provided to this function.
Fixed setting Show CPU Frequency checkbox so it works now instead of displaying <N/A>.
Assisted-by: Antigravity ai@google.com