Measure your CPU & RAM usage with performance watcher

Measure your CPU & RAM usage with performance watcher

The latest, 6th watcher, has been recently added to the Warden library. It’s probably the simplest one, but it doesn’t mean it’s barely useful. The performance watcher has been created in order to measure the CPU & RAM usage, simple as that. Sounds interesting? If that’s the case, you might find the whole note useful then.


 

Since this watcher is not so sophisticated while compared to the other ones, the example will be quite straightforward:

Or with the usage of available extensions:

At first, you may notice the delay, which is an optional parameter (50ms by default) related to the necessity of awaiting the performance check by the Performance Counter used under the hood. You don’t need to provide any value here, but certainly you can.
Then, you can check whether the CPU and/or RAM usage fall into the specific range.
In the example above, we’re checking whether the CPU usage is less than 30% and at least 3000 MB of free RAM is available. And that’s it – a simple watcher which might be useful on certain occasions.

To install the package (a prerelease version for now), run the following command in the Package Manager:

The custom configuration can be provided by implementing the following interface:

And then invoking the WithPerformanceProvider() when configuring the watcher.
To learn more about its technical details, please navigate to this page.

So what are my next goals? Currently, I’m working mostly on the Warden Web Panel – the first version is almost finished, so hopefully it will be released in the upcoming days.
And later on… well, let a surprise remain a surprise ;).

Leave A Comment

Your email address will not be published. Required fields are marked *