resusage 0.1.2

Virtual memory, RAM, CPU usage by system or process


To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:


This package provides sub packages which can be used individually:

resusage:totalusage - A minimal D application.

resusage:processusage - A minimal D application.

resusage:cpuwatcher - A minimal D application.

Resusage

Obtaining of virtual memory, RAM and CPU usage by the whole system or by single process.

Build Status

Currently works on Linux and Windows.

Documentation

Ddoc:

dub build --build=docs

Ddox:

dub build --build=ddox

Examples

Total usage

Prints total amount of virtual and physical memory and their current usage in the system, in bytes.

dub run resusage:totalusage 

Process usage

Prints amount of virtual and physical memory used by process.

dub run resusage:processusage -- `pidof process`

CPU Watcher

Watch system CPU time:

dub run resusage:cpuwatcher

Watch process CPU time:

dub run resusage:cpuwatcher -- `pidof process`

Platform notes and implementation details

Windows

In order to provide some functionality resusage dynamically loads the following libraries at startup:

  1. Psapi.dll to get memory (physical and virtual) used by specific process.
  2. Pdh.dll to calculate CPU time used by system.

If specific library could be loaded, corresponding functions will always throw WindowsException.

Linux

Value returned by physicalMemoryUsed can be bigger than RAM actually used by all system's processes. It's because Linux uses free memory for file cache to increase file access speed. This memory is still free for programs though, because the kernel will reallocate it when needed. To get memory used by processes, better consider using virtualMemoryUsed.

Authors:
  • Roman Chistokhodov
Sub packages:
resusage:totalusage, resusage:processusage, resusage:cpuwatcher
Dependencies:
none
Versions:
0.3.2 2020-Feb-21
0.3.1 2020-Feb-21
0.3.0 2019-Jul-26
0.2.8 2018-May-05
0.2.7 2017-Jul-01
Show all 17 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 4 downloads this month

  • 7944 downloads total

Score:
1.5
Short URL:
resusage.dub.pm