L4T Multimedia API Reference

32.2 Release

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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
uint64_t num_late_units
Number of units which arrived late at the element.
void printProfilerData(std::ostream &out_stream=std::cout)
Prints the element's profiling data to an output stream.
uint64_t startProcessing()
Informs the profiler that processing has started.
void finishProcessing(uint64_t id, bool is_late)
Informs the profiler that processing has finished.
uint64_t min_latency_usec
Minimum of latencies for each processed units, in microseconds.
static const ProfilerField PROFILER_FIELD_NONE
void getProfilerData(NvElementProfilerData &data)
Gets the profiling data for the element.
uint64_t total_processed_units
Total units processed.
float average_fps
Average rate at which the units were processed.
static const ProfilerField PROFILER_FIELD_FPS
static const ProfilerField PROFILER_FIELD_ALL
ProfilerField valid_fields
Valid Fields which are supported by the element.
static const ProfilerField PROFILER_FIELD_TOTAL_UNITS
Holds profiling data for the element.
Every element has a unique name that can be used for identifying the element in debug logs...
Definition: NvElement.h:63
uint64_t average_latency_usec
Average latency of all processed units, in microseconds.
void disableProfiling()
Disables the profiler.
static const ProfilerField PROFILER_FIELD_LATE_UNITS
uint64_t max_latency_usec
Maximum of latencies for each processed units, in microseconds.
void enableProfiling(bool reset_data)
Enables the profiler.
static const ProfilerField PROFILER_FIELD_LATENCIES