# NvElementProfiler Class Reference

`NvElementProfiler` is a helper class for profiling the performance of individual elements. More...

`#include <NvElementProfiler.h>`

List of all members.

## Classes

struct | NvElementProfilerData
| Holds profiling data for the element. More...
struct | NvElementProfilerDataInternal

## Public Types

typedef int | ProfilerField
| Data type indicating valid fields in NvElementProfilerData structure.

## Public Member Functions

void | getProfilerData (NvElementProfilerData &data)
| Get the profiling data for the element.
void | printProfilerData (std::ostream &out_stream=std::cout)
| Print the element's profiling data to an output stream.
uint64_t | startProcessing ()
| Inform the profiler processing has started.
void | finishProcessing (uint64_t id, bool is_late)
| Inform the profiler processing has finished.
void | enableProfiling (bool reset_data)
| Enable the profiler.
void | disableProfiling ()
| Disable the profiler.

## Static Public Attributes

static const ProfilerField | PROFILER_FIELD_NONE = 0
static const ProfilerField | PROFILER_FIELD_TOTAL_UNITS = 1
static const ProfilerField | PROFILER_FIELD_LATE_UNITS = 2
static const ProfilerField | PROFILER_FIELD_LATENCIES = 4
static const ProfilerField | PROFILER_FIELD_FPS = 8
static const ProfilerField | PROFILER_FIELD_ALL = (PROFILER_FIELD_FPS << 1) - 1

## Private Member Functions

void | reset ()
| Reset the profiler data.
| NvElementProfiler (ProfilerField fields)
| Constructor for NvElementProfiler.
| NvElementProfiler (const NvElementProfiler &that)
| Disallow copy constructor.
void | operator= (NvElementProfiler const &)
| Disallow assignment.
| ~NvElementProfiler ()

## Private Attributes

pthread_mutex_t | profiler_lock
| Mutex to synchronize multithreaded access to profiler data.
bool | enabled
| Flag indicating if profiler is enabled.
const ProfilerField | valid_fields
| Valid fields for the element.
NvElementProfiler::NvElementProfilerDataInternal | data_int
std::map< uint64_t, struct timeval > | unit_start_time_queue
| Queue used to maintain the timestamps of when the unit processing started.
uint64_t | unit_id_counter
| Unique ID of the last unit.

## Friends

class | NvElement

## Detailed Description

`NvElementProfiler` is a helper class for profiling the performance of individual elements.

NvElementProfiler currently measures processing latencies, average processing rate and number of units which arrived late at the element. This should be used internally by the components.

Components should call startProcessing() to indicate that a unit has been submitted for processing and finishProcessing() to indicate that a unit has finished processing. Components who do not require latency measurement need not call startProcessing().

Components can get data from NvElementProfiler using getProfilerData(). It fills the NvElementProfilerData structure. Components might not support all the fields available in the strcuture and so a variable valid_fields of type ProfilerField is also included in the structure.

Definition at line 56 of file NvElementProfiler.h.

## Member Typedef Documentation

typedef int NvElementProfiler::ProfilerField

Data type indicating valid fields in NvElementProfilerData structure.

Definition at line 61 of file NvElementProfiler.h.

## Constructor & Destructor Documentation

NvElementProfiler::NvElementProfiler | ( | ProfilerField | fields | ) | `[private]`

Constructor for NvElementProfiler.

Initializes internal data structures. The profiler is disabled by default.

Parameters:

  | fields |

Definition at line 52 of file NvElementProfiler.cpp.

NvElementProfiler::NvElementProfiler | ( | const NvElementProfiler & | that | ) | `[private]`

Disallow copy constructor.

NvElementProfiler::~NvElementProfiler | ( |  | ) | `[private]`

Definition at line 63 of file NvElementProfiler.cpp.

## Member Function Documentation

void NvElementProfiler::disableProfiling | ( |  | ) |

Disable the profiler.

Definition at line 90 of file NvElementProfiler.cpp.

void NvElementProfiler::enableProfiling | ( | bool | reset_data | ) |

Enable the profiler.

startProcessing() and finishProcessing() will not have any effect till the profiler is enabled.

Parameters:

  `[in]` | reset_data | Reset the profiled data.

Definition at line 71 of file NvElementProfiler.cpp.

void NvElementProfiler::finishProcessing | ( | uint64_t | id,
|  | bool | is_late |
| ) |  |  |

Inform the profiler processing has finished.

Has no effect if profiler is disabled.

Parameters:

  `[in]` | id | ID of the unit whose processing is finished, 0 if the first unit in the profiler's queue should be picked.
  `[in]` | is_late | Should be true if the frame arrived late at the element.

Definition at line 233 of file NvElementProfiler.cpp.

void NvElementProfiler::getProfilerData | ( | NvElementProfiler::NvElementProfilerData & | data | ) |

Get the profiling data for the element.

Parameters:

  `[out]` | data | Reference to the NvElementProfilerData structure which should be filled.

Definition at line 107 of file NvElementProfiler.cpp.

void NvElementProfiler::operator= | ( | NvElementProfiler const & |  | ) | `[private]`

Disallow assignment.

void NvElementProfiler::printProfilerData | ( | std::ostream & | out_stream = `std::cout` | ) |

Print the element's profiling data to an output stream.

Parameters:

  `[in]` | out_stream | Reference to a std::ostream.

Definition at line 167 of file NvElementProfiler.cpp.

void NvElementProfiler::reset | ( |  | ) | `[private]`

Reset the profiler data.

Definition at line 201 of file NvElementProfiler.cpp.

uint64_t NvElementProfiler::startProcessing | ( |  | ) |

Inform the profiler processing has started.

Has no effect if profiler is disabled.

Returns:
  ID of the unit, to be supplied with finishProcessing();.

Definition at line 210 of file NvElementProfiler.cpp.

## Friends And Related Function Documentation

friend class NvElement `[friend]`

Definition at line 199 of file NvElementProfiler.h.

## Member Data Documentation

NvElementProfiler::NvElementProfilerDataInternal NvElementProfiler::data_int `[private]`

bool NvElementProfiler::enabled `[private]`

Flag indicating if profiler is enabled.

Definition at line 153 of file NvElementProfiler.h.

const ProfilerField NvElementProfiler::PROFILER_FIELD_ALL = (PROFILER_FIELD_FPS << 1) - 1`[static]`

Definition at line 67 of file NvElementProfiler.h.

const ProfilerField NvElementProfiler::PROFILER_FIELD_FPS = 8`[static]`

Definition at line 66 of file NvElementProfiler.h.

const ProfilerField NvElementProfiler::PROFILER_FIELD_LATE_UNITS = 2`[static]`

Definition at line 64 of file NvElementProfiler.h.

const ProfilerField NvElementProfiler::PROFILER_FIELD_LATENCIES = 4`[static]`

Definition at line 65 of file NvElementProfiler.h.

const ProfilerField NvElementProfiler::PROFILER_FIELD_NONE = 0`[static]`

Definition at line 62 of file NvElementProfiler.h.

const ProfilerField NvElementProfiler::PROFILER_FIELD_TOTAL_UNITS = 1`[static]`

Definition at line 63 of file NvElementProfiler.h.

pthread_mutex_t NvElementProfiler::profiler_lock `[private]`

Mutex to synchronize multithreaded access to profiler data.

Definition at line 151 of file NvElementProfiler.h.

uint64_t NvElementProfiler::unit_id_counter `[private]`

Unique ID of the last unit.

Definition at line 178 of file NvElementProfiler.h.

std::map<uint64_t, struct timeval> NvElementProfiler::unit_start_time_queue `[private]`

Queue used to maintain the timestamps of when the unit processing started.

Required to calculate latency.

Definition at line 176 of file NvElementProfiler.h.

const ProfilerField NvElementProfiler::valid_fields `[private]`

Valid fields for the element.

Definition at line 155 of file NvElementProfiler.h.

The documentation for this class was generated from the following files:

- include/NvElementProfiler.h
- samples/common/classes/NvElementProfiler.cpp