Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: nucleo_encoder_stepper mbed-os-rest-api-V1-1
You are viewing an older revision! See the latest version
Homepage
If you are looking to measure the overall CPU Usage, call the working() function at the start of your code, and just call update() any time you want to read the cpu usage value. Easy as that!
If you want to measure the CPU usage of a particular algorithm, place the working() function call before the code, and place the stopped() function call at the end. This limits the measuring purely to the usage of that code. calling update() will then then give you the percentage result.
When creating a CPU_Usage object you pass in 2x arguments. the first is a timer object, and the second is a ballast number (in seconds) precise to a single precision float value. This number can be though of as a smoothing number, play with this number to suit your application.
The API is so simple It almost needs no introduction. But documentation will follow soon. In the mean time here are two demos to get you started: