# Request: getBatteryRemaining and getCpuUsage

**URL:** <https://forum.juce.com/t/request-getbatteryremaining-and-getcpuusage/5983>\
**Category:** General JUCE discussion\
**Created:** [December 5, 2010, 5:06pm UTC](https://forum.juce.com/t/request-getbatteryremaining-and-getcpuusage/5983 "2010-12-05T17:06:52Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![TheVinn](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/thevinn/32/806_2.png) [@TheVinn](https://forum.juce.com/u/TheVinn)\
**Post date:** [December 5, 2010, 5:06pm UTC](https://forum.juce.com/t/request-getbatteryremaining-and-getcpuusage/5983/1 "2010-12-05T17:06:52Z")

</div>

More is better! I would love to see the following routines added to Juce (for all platforms of course)

int getBatteryPercentRemaining();

int getPercentageCpuUsage();

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [December 5, 2010, 6:30pm UTC](https://forum.juce.com/t/request-getbatteryremaining-and-getcpuusage/5983/2 "2010-12-05T18:30:17Z")

</div>

More is certainly better!

I’d never thought about battery life, I guess that’d be quite straightforward to do.

The cpu percentage is something I have considered, but when you start thinking about it, it starts to sound like it could be a bit of a can of worms - e.g. when there are multiple cpus, how exactly do you work out the total, and what if you want to get the percentage for particular processes. threads, etc… Feels like it could end up being a feature-creep nightmare. It’s also quite fiddly to get these numbers on some OSes.

---

<div class="post-metadata">

**Author:** ![TheVinn](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/thevinn/32/806_2.png) [@TheVinn](https://forum.juce.com/u/TheVinn)\
**Post date:** [December 5, 2010, 6:45pm UTC](https://forum.juce.com/t/request-getbatteryremaining-and-getcpuusage/5983/3 "2010-12-05T18:45:26Z")

</div>

Well on Windows the function is “GetSystemPowerStatus()”.

As for the CPU, since Juce is heavily used for plugins, audio hosting apps, digital audio workstations, etc… really the use-case is just so the application can show the user if they are close to being maxed-out on CPU. In which case, bad things might happen like audio dropouts, buffer underruns or overruns, and what not.

So I think just a general CPU function that tells you to what extent you are using up the CPU resources available, would be great. It doesn’t have to be just for the current process in fact it should be for the system as a whole, including everything else that is running (since they are using up resources).

---

<div class="post-metadata">

**Author:** ![TheVinn](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/thevinn/32/806_2.png) [@TheVinn](https://forum.juce.com/u/TheVinn)\
**Post date:** [December 5, 2010, 6:49pm UTC](https://forum.juce.com/t/request-getbatteryremaining-and-getcpuusage/5983/4 "2010-12-05T18:49:39Z")

</div>

Now that I think of it, another choice for measuring CPU usage would be to compare the ratio of time spent inside the interrupt-driven audio hardware callback, to the total time. In other words, how much headroom does the audio processing callback have available before it can’t keep up.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [December 5, 2010, 8:17pm UTC](https://forum.juce.com/t/request-getbatteryremaining-and-getcpuusage/5983/5 "2010-12-05T20:17:54Z")

</div>

> [@TheVinn](#):
>
> Now that I think of it, another choice for measuring CPU usage would be to compare the ratio of time spent inside the interrupt-driven audio hardware callback, to the total time. In other words, how much headroom does the audio processing callback have available before it can’t keep up.

You can already get that value with AudioDeviceManager::getCpuUsage()

---

<div class="post-metadata">

**Author:** ![TheVinn](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/thevinn/32/806_2.png) [@TheVinn](https://forum.juce.com/u/TheVinn)\
**Post date:** [December 5, 2010, 8:37pm UTC](https://forum.juce.com/t/request-getbatteryremaining-and-getcpuusage/5983/6 "2010-12-05T20:37:13Z")

</div>

> [@jules](#):
>
> You can already get that value with AudioDeviceManager::getCpuUsage()

Wow…now that is amazing!

---

<div class="post-metadata">

**Author:** ![TheVinn](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/thevinn/32/806_2.png) [@TheVinn](https://forum.juce.com/u/TheVinn)\
**Post date:** [February 26, 2011, 2:54pm UTC](https://forum.juce.com/t/request-getbatteryremaining-and-getcpuusage/5983/7 "2011-02-26T14:54:43Z")

</div>

getCpuUsage() is awesome.

Any word on battery? This could be useful on iOs and Android

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [February 26, 2011, 5:38pm UTC](https://forum.juce.com/t/request-getbatteryremaining-and-getcpuusage/5983/8 "2011-02-26T17:38:41Z")

</div>

> [@](#):
>
> Any word on battery? This could be useful on iOs and Android

It’s not something I’ve ever investigated. Am doing a lot more mobile work at the moment though, so may add it.

---

<div class="post-metadata">

**Author:** ![waverley-instruments](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/waverley-instruments/32/20118_2.png) [@waverley-instruments](https://forum.juce.com/u/waverley-instruments)\
**Post date:** [June 14, 2026, 5:31pm UTC](https://forum.juce.com/t/request-getbatteryremaining-and-getcpuusage/5983/9 "2026-06-14T17:31:08Z")

</div>

Sorry to kick up the dust on an _ **ancient** _ thread, but I guess this never got added?

I’d been hoping to add a large battery display monitor to a utility plugin as it’d be super handy for live performances with an iPad for example if you’re not running external power.

Alternatively, a reasonably clean way of hooking out the battery status with C++ / JUCE that works on iOS and macOS would be much appreciated. Cheers, -Rob

PS. I know we already have CPU usage, so all good there.
