123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223 |
- #ifndef __NV_ELEMENT_PROFILER_H__
- #define __NV_ELEMENT_PROFILER_H__
- #include <iostream>
- #include <pthread.h>
- #include <map>
- #include <stdint.h>
- #include <sys/time.h>
- class NvElementProfiler {
- public:
-
- typedef int ProfilerField;
- 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;
-
-
- typedef struct {
-
- ProfilerField valid_fields;
-
- uint64_t average_latency_usec;
-
- uint64_t min_latency_usec;
-
- uint64_t max_latency_usec;
-
- uint64_t total_processed_units;
-
- uint64_t num_late_units;
-
- float average_fps;
-
- struct timeval profiling_time;
- } NvElementProfilerData;
-
- void getProfilerData(NvElementProfilerData &data);
-
- void printProfilerData(std::ostream &out_stream = std::cout);
-
- uint64_t startProcessing();
-
- void finishProcessing(uint64_t id, bool is_late);
-
- void enableProfiling(bool reset_data);
-
- void disableProfiling();
- private:
-
- void reset();
- pthread_mutex_t profiler_lock;
- bool enabled;
- const ProfilerField valid_fields;
- struct NvElementProfilerDataInternal : NvElementProfilerData {
-
- struct timeval start_time;
-
- struct timeval stop_time;
-
- struct timeval accumulated_time;
-
- uint64_t total_latency;
- } data_int;
-
- std::map<uint64_t, struct timeval> unit_start_time_queue;
- uint64_t unit_id_counter;
-
- NvElementProfiler(ProfilerField fields);
-
- NvElementProfiler(const NvElementProfiler& that);
-
- void operator=(NvElementProfiler const&);
- ~NvElementProfiler();
- friend class NvElement;
- };
- #endif
|