CppUProfile
Functions
Functions for monitoring system metrics

Functions

void uprofile::start (const char *filepath, unsigned long long maxCapSize=0)
 Start profiling to periodically record monitored events to a file. More...
 
void uprofile::stop ()
 Stop all monitorings. More...
 
void uprofile::addGPUMonitor (IGPUMonitor *monitor)
 Inject a GPUMonitor object that will be responsible for monitoring GPU metrics (usage and memory) More...
 
void uprofile::removeGPUMonitor ()
 Destroy injected GPUMonitor object.
 
void uprofile::setTimestampUnit (TimestampUnit tsUnit)
 Change the timestamp unit to record profiling metrics. More...
 
void uprofile::timeBegin (const std::string &title)
 Start monitoring the execution time of the given event. More...
 
void uprofile::timeEnd (const std::string &title)
 Stop monitoring the execution time of the given event. More...
 
void uprofile::startProcessMemoryMonitoring (int period)
 Start monitoring of the memory used by the process. More...
 
void uprofile::startSystemMemoryMonitoring (int period)
 Start monitoring of the global memory used on the system. More...
 
void uprofile::startCPUUsageMonitoring (int period)
 Start monitoring of the usage percentage of each CPU. More...
 
void uprofile::startGPUUsageMonitoring (int period)
 Start monitoring of the usage of the GPU. More...
 
void uprofile::startGPUMemoryMonitoring (int period)
 Start monitoring of the usage of the GPU memory. More...
 
void uprofile::getProcessMemory (int &rss, int &shared)
 memory used by the current process
 
void uprofile::getSystemMemory (int &totalMem, int &availableMem, int &freeMem)
 dump global system memory
 
std::vector< float > uprofile::getInstantCpuUsage ()
 get usage of all cpu cores More...
 

Detailed Description

Function Documentation

◆ addGPUMonitor()

void uprofile::addGPUMonitor ( IGPUMonitor *  monitor)

Inject a GPUMonitor object that will be responsible for monitoring GPU metrics (usage and memory)

Parameters
monitorcustom GPUMonitor object

Note: uprofile takes ownership of the passed object.

◆ getInstantCpuUsage()

std::vector<float> uprofile::getInstantCpuUsage ( )

get usage of all cpu cores

Returns
vector holding the usage percentage of each CPU core

◆ setTimestampUnit()

void uprofile::setTimestampUnit ( TimestampUnit  tsUnit)

Change the timestamp unit to record profiling metrics.

It should be called before calling start() method.

Note: default value is EPOCH_TIME

◆ start()

void uprofile::start ( const char *  filepath,
unsigned long long  maxCapSize = 0 
)

Start profiling to periodically record monitored events to a file.

Parameters
filepathfile path where events will be saved
maxCapSizemaximum file size in bytes

By default, the file is unbounded.

If you have some storage constraints, set maxCapSize parameter for generating two rotating files (<file>_0.<ext> and <file>_1.<ext>) Each file will have a maximum size of maxCapSize/2 (In this mode, more recent events will override older events)

◆ startCPUUsageMonitoring()

void uprofile::startCPUUsageMonitoring ( int  period)

Start monitoring of the usage percentage of each CPU.

Parameters
periodperiod between two cpu usage dump (in ms)

◆ startGPUMemoryMonitoring()

void uprofile::startGPUMemoryMonitoring ( int  period)

Start monitoring of the usage of the GPU memory.

Parameters
periodperiod between two gpu usage dump (in ms)

◆ startGPUUsageMonitoring()

void uprofile::startGPUUsageMonitoring ( int  period)

Start monitoring of the usage of the GPU.

Parameters
periodperiod between two gpu usage dump (in ms)

◆ startProcessMemoryMonitoring()

void uprofile::startProcessMemoryMonitoring ( int  period)

Start monitoring of the memory used by the process.

Parameters
periodperiod between two memory dump (in ms)

◆ startSystemMemoryMonitoring()

void uprofile::startSystemMemoryMonitoring ( int  period)

Start monitoring of the global memory used on the system.

Parameters
periodperiod between two memory dump (in ms)

◆ stop()

void uprofile::stop ( )

Stop all monitorings.

Note: stopping profiler without prior call to start() has no effect

◆ timeBegin()

void uprofile::timeBegin ( const std::string &  title)

Start monitoring the execution time of the given event.

Parameters
titleevent key

◆ timeEnd()

void uprofile::timeEnd ( const std::string &  title)

Stop monitoring the execution time of the given event.

The library computes the duration for the given event and saves it into the report file.

If no timeBegin() has been called with the given title, the call is ignored.