Jetson Linux API Reference

32.7.5 Release
NvElementProfiler.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * * Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * * Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  * * Neither the name of NVIDIA CORPORATION nor the names of its
13  * contributors may be used to endorse or promote products derived
14  * from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
17  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
20  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
24  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #ifndef __NV_ELEMENT_PROFILER_H__
30 #define __NV_ELEMENT_PROFILER_H__
31 
32 #include <iostream>
33 #include <pthread.h>
34 #include <map>
35 #include <stdint.h>
36 #include <sys/time.h>
37 
73 public:
79  typedef int ProfilerField;
94  typedef struct {
97 
104 
108  uint64_t num_late_units;
109 
111  float average_fps;
112 
114  struct timeval profiling_time;
116 
123 
129  void printProfilerData(std::ostream &out_stream = std::cout);
130 
138  uint64_t startProcessing();
139 
149  void finishProcessing(uint64_t id, bool is_late);
150 
158  void enableProfiling(bool reset_data);
159 
163  void disableProfiling();
164 private:
168  void reset();
169 
170  pthread_mutex_t profiler_lock;
172  bool enabled;
174  const ProfilerField valid_fields;
176  struct NvElementProfilerDataInternal : NvElementProfilerData {
178  struct timeval start_time;
179 
181  struct timeval stop_time;
182 
187  struct timeval accumulated_time;
188 
190  uint64_t total_latency;
191  } data_int;
192 
195  std::map<uint64_t, struct timeval> unit_start_time_queue;
196 
197  uint64_t unit_id_counter;
206 
214  void operator=(NvElementProfiler const&);
215 
217 
218  friend class NvElement;
219 };
220 
223 #endif
NvElementProfiler::NvElementProfilerData::valid_fields
ProfilerField valid_fields
Valid Fields which are supported by the element.
Definition: NvElementProfiler.h:96
NvElementProfiler
Definition: NvElementProfiler.h:72
NvElementProfiler::enableProfiling
void enableProfiling(bool reset_data)
Enables the profiler.
NvElementProfiler::PROFILER_FIELD_LATE_UNITS
static const ProfilerField PROFILER_FIELD_LATE_UNITS
Definition: NvElementProfiler.h:82
NvElementProfiler::ProfilerField
int ProfilerField
Definition: NvElementProfiler.h:79
NvElementProfiler::printProfilerData
void printProfilerData(std::ostream &out_stream=std::cout)
Prints the element's profiling data to an output stream.
NvElementProfiler::startProcessing
uint64_t startProcessing()
Informs the profiler that processing has started.
NvElementProfiler::NvElementProfilerData::total_processed_units
uint64_t total_processed_units
Total units processed.
Definition: NvElementProfiler.h:106
NvElementProfiler::NvElementProfilerData::average_fps
float average_fps
Average rate at which the units were processed.
Definition: NvElementProfiler.h:111
NvElementProfiler::NvElementProfilerData::num_late_units
uint64_t num_late_units
Number of units which arrived late at the element.
Definition: NvElementProfiler.h:108
NvElementProfiler::NvElementProfilerData
Holds profiling data for the element.
Definition: NvElementProfiler.h:94
NvElementProfiler::PROFILER_FIELD_LATENCIES
static const ProfilerField PROFILER_FIELD_LATENCIES
Definition: NvElementProfiler.h:83
NvElementProfiler::NvElementProfilerData::max_latency_usec
uint64_t max_latency_usec
Maximum of latencies for each processed units, in microseconds.
Definition: NvElementProfiler.h:103
NvElementProfiler::PROFILER_FIELD_NONE
static const ProfilerField PROFILER_FIELD_NONE
Definition: NvElementProfiler.h:80
NvElementProfiler::PROFILER_FIELD_FPS
static const ProfilerField PROFILER_FIELD_FPS
Definition: NvElementProfiler.h:84
NvElement
Every element has a unique name that can be used for identifying the element in debug logs.
Definition: NvElement.h:63
NvElementProfiler::PROFILER_FIELD_ALL
static const ProfilerField PROFILER_FIELD_ALL
Definition: NvElementProfiler.h:85
NvElementProfiler::PROFILER_FIELD_TOTAL_UNITS
static const ProfilerField PROFILER_FIELD_TOTAL_UNITS
Definition: NvElementProfiler.h:81
NvElementProfiler::disableProfiling
void disableProfiling()
Disables the profiler.
NvElementProfiler::finishProcessing
void finishProcessing(uint64_t id, bool is_late)
Informs the profiler that processing has finished.
NvElementProfiler::NvElementProfilerData::average_latency_usec
uint64_t average_latency_usec
Average latency of all processed units, in microseconds.
Definition: NvElementProfiler.h:99
NvElementProfiler::NvElementProfilerData::min_latency_usec
uint64_t min_latency_usec
Minimum of latencies for each processed units, in microseconds.
Definition: NvElementProfiler.h:101
NvElementProfiler::getProfilerData
void getProfilerData(NvElementProfilerData &data)
Gets the profiling data for the element.