Jetson Linux API 参考文档

32.7.4 版本
NvApplicationProfiler.h
转到此文件的文档。
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 
36 #ifndef __NV_PROFILER_H__
37 #define __NV_PROFILER_H__
38 
39 #include <iostream>
40 #include <pthread.h>
41 #include <stdint.h>
42 #include <sys/time.h>
43 #include <time.h>
44 
68 {
69 public
73  typedef struct
74  {
76  struct timeval total_time;
82  uint32_t num_cpu_cores;
84  uint32_t cpu_freq_mhz;
86 
87  static const uint64_t DefaultSamplingInterval = 100;
88 
95 
105  void start(uint32_t sampling_interval_ms);
106 
110  void stop();
111 
118  void printProfilerData(std::ostream &outstream = std::cout);
119 
126 
127 private
136  static void * ProfilerThread(void *);
137 
138  bool running;
139  uint32_t sampling_interval;
142  pthread_mutex_t thread_lock;
144  pthread_t profiling_thread;
147  uint32_t num_cpu_cores;
148  uint32_t cpu_freq;
149  bool check_cpu_usage;
154  struct ProfilerDataInternal
155  {
157  struct timeval start_time;
159  struct timeval stop_time;
160 
163  struct timespec start_proc_cpu_clock_time;
165  struct timespec start_cpu_clock_time;
166 
169  struct timespec stop_proc_cpu_clock_time;
171  struct timespec stop_cpu_clock_time;
172 
174  float max_cpu_usage;
176  float min_cpu_usage;
178  float avg_cpu_usage;
179 
181  uint64_t num_readings;
182  } data;
187  void profile();
188 
193 
201  void operator=(NvApplicationProfiler const&);
202 };
203 
206 #endif
NvApplicationProfiler::getProfilerData
void getProfilerData(NvAppProfilerData &data)
获取性能分析器数据。
NvApplicationProfiler::NvAppProfilerData
保存性能分析数据。
Definition: NvApplicationProfiler.h:73
NvApplicationProfiler
Definition: NvApplicationProfiler.h:67
NvApplicationProfiler::printProfilerData
void printProfilerData(std::ostream &outstream=std::cout)
将性能分析器数据打印到输出流。
NvApplicationProfiler::NvAppProfilerData::num_cpu_cores
uint32_t num_cpu_cores
CPU 核心数量。
Definition: NvApplicationProfiler.h:82
NvApplicationProfiler::NvAppProfilerData::cpu_freq_mhz
uint32_t cpu_freq_mhz
CPU 的运行频率,单位为 MHz。
Definition: NvApplicationProfiler.h:84
NvApplicationProfiler::start
void start(uint32_t sampling_interval_ms)
使用指定的采样间隔启动性能分析器。
NvApplicationProfiler::stop
void stop()
停止性能分析器。
NvApplicationProfiler::DefaultSamplingInterval
static const uint64_t DefaultSamplingInterval
Definition: NvApplicationProfiler.h:87
NvApplicationProfiler::NvAppProfilerData::avg_cpu_usage
float avg_cpu_usage
整个性能分析期间的平均 CPU 使用率。
Definition: NvApplicationProfiler.h:80
NvApplicationProfiler::NvAppProfilerData::peak_cpu_usage
float peak_cpu_usage
性能分析期间的峰值 CPU 使用率。
Definition: NvApplicationProfiler.h:78
NvApplicationProfiler::getProfilerInstance
static NvApplicationProfiler & getProfilerInstance()
获取对全局 NvApplicationProfiler 实例的引用。
. All rights reserved.