NIST Biometric Evaluation Framework
Software components for biometric technology evaluations
be_process_statistics.h
Go to the documentation of this file.
1/*
2 * This software was developed at the National Institute of Standards and
3 * Technology (NIST) by employees of the Federal Government in the course
4 * of their official duties. Pursuant to title 17 Section 105 of the
5 * United States Code, this software is not subject to copyright protection
6 * and is in the public domain. NIST assumes no responsibility whatsoever for
7 * its use by other parties, and makes no guarantees, expressed or implied,
8 * about its quality, reliability, or any other characteristic.
9 */
10
11#ifndef __BE_PROCESS_STATISTICS_H__
12#define __BE_PROCESS_STATISTICS_H__
13
14#include <pthread.h>
15
16#include <memory>
17#include <optional>
18#include <tuple>
19
21
22namespace BiometricEvaluation {
23 namespace Process {
24
45 class Statistics {
46 public:
47
52
75 Statistics(const std::shared_ptr<IO::FileLogCabinet>
76 &logCabinet, bool doTasksLogging = false);
77
95 const std::shared_ptr<IO::Logsheet> &logSheet,
96 std::optional<std::shared_ptr<IO::Logsheet>>
97 tasksLogSheet = std::nullopt);
98
100
125 std::tuple<
126 uint64_t,
127 uint64_t> getCPUTimes();
128
157 std::vector<std::tuple<
158 pid_t,
159 float,
160 float>> getTasksStats();
161
186 std::tuple<
187 uint64_t,
188 uint64_t,
189 uint64_t,
190 uint64_t,
191 uint64_t> getMemorySizes();
192
206 uint32_t getNumThreads();
207
223 void logStats();
224
253 void startAutoLogging(uint64_t interval);
254
266
274
275 private:
276
277 pid_t _pid;
278 std::shared_ptr<IO::FileLogCabinet> _logCabinet{};
279 std::shared_ptr<IO::Logsheet> _logSheet{};
280 std::optional<std::shared_ptr<IO::Logsheet>>
281 _tasksLogSheet{};
282 bool _logging{};
283 pid_t _loggingTaskID{};
284 bool _doTasksLogging{};
285 bool _autoLogging{};
286 pthread_t _loggingThread{};
287 pthread_mutex_t _logMutex{};
288 };
289
290 }
291}
292#endif /* __BE_PROCESS_STATISTICS_H__ */
The Statistics class provides an interface for gathering process statistics, such as memory usage,...
std::tuple< uint64_t, uint64_t, uint64_t, uint64_t, uint64_t > getMemorySizes()
Obtain the current virtual memory (VM) set sizes for the process, in kilobytes.
void logStats()
Create a snapshot of the current process statistics in the FileLogsheet created in the FileLogCabinet...
std::tuple< uint64_t, uint64_t > getCPUTimes()
Obtain the total user and system times for the process, in microseconds.
uint32_t getNumThreads()
Obtain the number of threads composing this process.
Statistics(const std::shared_ptr< IO::FileLogCabinet > &logCabinet, bool doTasksLogging=false)
Construct a Statistics object with the associated FileLogCabinet.
void startAutoLogging(uint64_t interval)
Start logging process statistics automatically, in intervals of microseconds.
void callStatistics_logStats()
Helper function in C++ space that has access to this object, and is called from C space by the loggin...
std::vector< std::tuple< pid_t, float, float > > getTasksStats()
Obtain the current child tasks statistics for the process.
void stopAutoLogging()
Stop the automatic logging of process statistics.
Statistics()
Constructor with no parameters.
Statistics(const std::shared_ptr< IO::Logsheet > &logSheet, std::optional< std::shared_ptr< IO::Logsheet > > tasksLogSheet=std::nullopt)
Construct a Statistic object that logs to an existing Logsheet.
This software was developed at the National Institute of Standards and Technology (NIST) by employees...