我在Jetson TX2上配置C ++代码时遇到问题。配置文件本身可以工作,但是我没有得到函数名,而是说它的一部分是未知的。 我用go安装了pprof,它可以在我的Raspberry Pi上运行,我想id做正确的步骤。例如我的Jetson和我的Pi之间的区别:
我在Jetson上得到的结果是:
LD_PRELOAD="/usr/lib/libprofiler.so.0" CPUPROFILE=./tmp/profile.log ./testProg
Worker threads activated: 1
Done
PROFILE: interrupts/evictions/bytes = 3792/1650/150928
pprof --functions --text ./testProg ./tmp/profile.log
Some binary filenames not available. Symbolization may be incomplete.
Try setting PPROF_BINARY_PATH to the search path for local binaries.
File: testProg
Type: cpu
Showing nodes accounting for 37.15s, 97.97% of 37.92s total
Dropped 38 nodes (cum <= 0.19s)
flat flat% sum% cum cum%
16s 42.19% 42.19% 16s 42.19% inflateBackEnd
5.88s 15.51% 57.70% 5.88s 15.51% cv::(anonymous namespace)::medianBlur_SortNet
3.92s 10.34% 68.04% 3.92s 10.34% png_get_uint_16
2.86s 7.54% 75.58% 2.86s 7.54% inflate
1.89s 4.98% 80.56% 1.89s 4.98% adler32
1.15s 3.03% 83.60% 1.15s 3.03% memcpy
1.13s 2.98% 86.58% 1.13s 2.98% png_set_invert_mono
0.93s 2.45% 89.03% 0.93s 2.45% crc32
0.68s 1.79% 90.82% 0.68s 1.79% carotene_o4t::bgr2gray
0.62s 1.64% 92.46% 0.62s 1.64% sched_yield
0.48s 1.27% 93.72% 0.48s 1.27% [[vdso]]
0.48s 1.27% 94.99% 0.48s 1.27% cv::ThresholdRunner::operator()
0.47s 1.24% 96.23% 0.47s 1.24% inflateMark
0.37s 0.98% 97.20% 0.37s 0.98% read
0.29s 0.76% 97.97% 0.29s 0.76% cvFindNextContour
0 0% 97.97% 37.92s 100%
在Pi上我得到:
LD_PRELOAD="/usr/lib/libprofiler.so.0" CPUPROFILE=./tmp/profile.log ./testProg
Worker threads activated: 1
Done
PROFILE: interrupts/evictions/bytes = 16223/283/24060
pprof --functions --text ./testProg ./tmp/profile.log
File: testProg
Type: cpu
Showing nodes accounting for 159.98s, 98.61% of 162.23s total
Dropped 97 nodes (cum <= 0.81s)
flat flat% sum% cum cum%
75.63s 46.62% 46.62% 75.63s 46.62% cv::medianBlur_8u_Om
37.26s 22.97% 69.59% 37.26s 22.97% inflateBackEnd
11.58s 7.14% 76.72% 11.58s 7.14% png_set_read_user_transform_fn
6.45s 3.98% 80.70% 6.45s 3.98% memcmp
5.45s 3.36% 84.06% 5.45s 3.36% inflate
4.46s 2.75% 86.81% 4.46s 2.75% adler32
3.91s 2.41% 89.22% 3.91s 2.41% png_set_invert_mono
3.86s 2.38% 91.60% 3.87s 2.39% cvFindNextContour
2.97s 1.83% 93.43% 2.97s 1.83% cv::CvtColorLoop_Invoker::operator()
2s 1.23% 94.66% 2s 1.23% read
1.90s 1.17% 95.83% 1.90s 1.17% cv::ThresholdRunner::operator()
1.80s 1.11% 96.94% 1.80s 1.11% crc32
1.25s 0.77% 97.71% 1.25s 0.77% munmap
1.22s 0.75% 98.47% 1.22s 0.75% inflateMark
0.10s 0.062% 98.53% 5.40s 3.33% tbb::empty_task::~empty_task
0.03s 0.018% 98.55% 2.04s 1.26% __GI__IO_file_xsgetn
0.02s 0.012% 98.56% 3.14s 1.94% rml::internal::thread_monitor::detach_thread
0.02s 0.012% 98.57% 4.91s 3.03% tbb::interface7::internal::start_for::execute
0.01s 0.0062% 98.58% 2.05s 1.26% _GI__IO_fread
0.01s 0.0062% 98.58% 4.18s 2.58% cv::findContours
0.01s 0.0062% 98.59% 2.33s 1.44% cv::parallel_for
0.01s 0.0062% 98.59% 4.24s 2.61% imgprocessing::blobfind
0.01s 0.0062% 98.60% 2.31s 1.42% tbb::interface7::internal::delegated_function::operator()
0.01s 0.0062% 98.61% 2.32s 1.43% tbb::interface7::internal::task_arena_base::internal_execute
0.01s 0.0062% 98.61% 3.12s 1.92% tbb::task_scheduler_init::initialize
0 0% 98.61% 1.30s 0.8% _IO_new_file_underflow
0 0% 98.61% 82.20s 50.67% __libc_start_main
0 0% 98.61% 1.72s 1.06% cv::cvtColor
0 0% 98.61% 1.72s 1.06% cv::cvtColorBGR2Gray
0 0% 98.61% 1.71s 1.05% cv::hal::cvtBGRtoGray
0 0% 98.61% 75.65s 46.63% cv::medianBlur
0 0% 98.61% 76.06s 46.88% imgprocessing::filter_img (inline)
0 0% 98.61% 82.20s 50.67% imgprocessing::process
0 0% 98.61% 82.20s 50.67% main
0 0% 98.61% 2.30s 1.42% tbb::interface7::internal::start_for::run
如您所见,对我使用的OpenCV函数进行性能分析工作正常,但是我自己的代码称为unknown。
我在编译时启用了-g标志。 我使用以下行来分析我的代码(makefile)
LD_PRELOAD="/usr/lib/libprofiler.so.0" CPUPROFILE=./tmp/profile.log ./$(PROG)
pprof --functions --text ./$(PROG) ./tmp/profile.log
...当我使用google-pprof而不是pprof时,我不会得到未知的信息,而只会得到地址(例如0x0000007f7a090498)。我试图解决错误,但没有成功。 我尝试了很多,然后猜测是将地址与函数名称耦合在一起。当我尝试addr2line时,我得到:
addr2line -e testProg 0x7f7a090498
??:0
我希望有人能帮助我。