The Statistics class provides an interface for gathering process statistics, such as memory usage, system time, etc.
More...
#include <be_process_statistics.h>
The Statistics class provides an interface for gathering process statistics, such as memory usage, system time, etc.
The information gathered by objects of this class are for the current process, and can optionally be logged to a FileLogsheet object contained within the provided FileLogCabinet.
- Note
- The resolution of a returned value for many methods may not match the resolution allowed by the interface. For example, the operating system my allow for second resolution whereas the interface allows microsecond resolution.
Definition at line 42 of file be_process_statistics.h.
◆ Statistics() [1/3]
| BiometricEvaluation::Process::Statistics::Statistics |
( |
| ) |
|
Constructor with no parameters.
◆ Statistics() [2/3]
| BiometricEvaluation::Process::Statistics::Statistics |
( |
const std::shared_ptr< IO::FileLogCabinet > & |
logCabinet | ) |
|
Construct a Statistics object with the associated FileLogCabinet.
- Parameters
-
| [in] | logCabinet | The FileLogCabinet obejct where this object will create a FileLogsheet to contain the statistic information for the process. |
- Exceptions
-
| Error::NotImplemented | Logging is not supported on this OS. This exception can be thrown when any portion of the statistics gathering cannot be completed. |
| Error::ObjectExists | The FileLogsheet already exists. This exception should rarely, if ever, occur. |
| Error::StrategyError | Failure to create the FileLogsheet in the cabinet. |
◆ Statistics() [3/3]
| BiometricEvaluation::Process::Statistics::Statistics |
( |
const std::shared_ptr< IO::Logsheet > & |
logSheet | ) |
|
Construct a Statistic object that logs to an existing Logsheet.
- Parameters
-
| [in] | logSheet | Existing Logsheet that will be appended. |
- Exceptions
-
| Error::NotImplemented | Logging is not supported on this OS. This exception can be thrown when any portion of the statistics gathering cannot be completed. |
◆ ~Statistics()
| BiometricEvaluation::Process::Statistics::~Statistics |
( |
| ) |
|
◆ getCPUTimes()
| std::tuple< uint64_t, uint64_t > BiometricEvaluation::Process::Statistics::getCPUTimes |
( |
| ) |
|
Obtain the total user and system times for the process, in microseconds.
An example call:
uint64_t utime, stime;
std::tie(utime, stime) = stats.getCPUTimes();
- Note
- This method may not be implemented in all operating systems.
- Returns
- A std::tuple<> containing user time, system time.
- Exceptions
-
| Error::StrategyError | An error occurred when obtaining the process statistics from the operating system. The exception information string contains the error reason. |
| Error::NotImplemented | This method is not implemented on this OS. |
◆ getMemorySizes()
| std::tuple< uint64_t, uint64_t, uint64_t, uint64_t, uint64_t > BiometricEvaluation::Process::Statistics::getMemorySizes |
( |
| ) |
|
Obtain the current virtual memory (VM) set sizes for the process, in kilobytes.
An example call:
uint64_t vmrss, vmsize, vmpeak, vmdata, vmstack;
std::tie(vmrss, vmsize, vmpeak, vmdata, vmstack)
= stats.getMemorySizes();
- Note
- This method may not be implemented in all operating systems.
- Returns
- A std::tuple<> containing VM resident size, VM size, VM peak, VM data size, VM stack size.
- Exceptions
-
| Error::StrategyError | An error occurred when obtaining the process statistics from the operating system. The exception information string contains the error reason. |
| Error::NotImplemented | This method is not implemented on this OS. |
◆ getNumThreads()
| uint32_t BiometricEvaluation::Process::Statistics::getNumThreads |
( |
| ) |
|
Obtain the number of threads composing this process.
- Note
- This method may not be implemented in all operating systems.
- Exceptions
-
| Error::StrategyError | An error occurred when obtaining the process info from the operating system. The exception information string contains the error reason. |
| Error::NotImplemented | This method is not implemented on this OS. |
◆ logStats()
| void BiometricEvaluation::Process::Statistics::logStats |
( |
| ) |
|
Create a snapshot of the current process statistics in the FileLogsheet created in the FileLogCabinet.
- Exceptions
-
◆ startAutoLogging()
| void BiometricEvaluation::Process::Statistics::startAutoLogging |
( |
uint64_t |
interval | ) |
|
Start logging process statistics automatically, in intervals of microseconds.
The first log entry will occur soon after the call to this method as the delay interval is invoked after the first entry.
- Note
- It is unrealistic to expect that log entries can be made at a rate of one per microsecond.
-
If stopAutoLogging() is called very soon after the start, a log entry may not be made.
- Parameters
-
| [in] | interval | The gap between logging snapshots, in microseconds. |
- Exceptions
-
◆ stopAutoLogging()
| void BiometricEvaluation::Process::Statistics::stopAutoLogging |
( |
| ) |
|
Stop the automatic logging of process statistics.
- Exceptions
-
◆ callStatistics_logStats()
| void BiometricEvaluation::Process::Statistics::callStatistics_logStats |
( |
| ) |
|
Helper function in C++ space that has access to this object, and is called from C space by the logging thread.
Applications should not call this function.
The documentation for this class was generated from the following file: