简体   繁体   English

使用OProfile对OpenCV进行性能分析

[英]Profiling OpenCV using OProfile

I have this basic OpenCV program: 我有这个基本的OpenCV程序:

#include <iostream>
#include "opencv2/opencv.hpp"

int main(){

    std::cout<<"Reading Image..."<<std::endl;
    cv::Mat img = cv::imread("all_souls_000000.jpg", cv::IMREAD_GRAYSCALE);
    if(!img.data)
        std::cerr<<"Error reading image"<<std::endl;
    return 0;
}

Which creates the executable ReadImage . 创建可执行文件ReadImage I want to profile it using OProfile. 我想使用OProfile对其进行分析。 However, running: 但是,运行:

operf ./ReadImage > ReadImage.log

Returns: 返回:

Kernel profiling is not possible with current system config.
Set /proc/sys/kernel/kptr_restrict to 0 to collect kernel samples.
operf: Profiler started
* * * * WARNING: Profiling rate was throttled back by the kernel * * * *
The number of samples actually recorded is less than expected, but is
probably still statistically valid.  Decreasing the sampling rate is the
best option if you want to avoid throttling.

Profiling done.

Why this happens? 为什么会这样? What is the best way to profile OpenCV? 剖析OpenCV的最佳方法是什么?

I was able to run operf on an opencv app, with this result, is this what you are looking for? 我能够在opencv应用程序上运行operf ,结果是,这就是您想要的吗?

Profiling started at Tue Jan 31 16:52:48 2017
Profiling stopped at Tue Jan 31 16:52:53 2017

-- OProfile/operf Statistics --
Nr. non-backtrace samples: 337018
Nr. kernel samples: 5603
Nr. user space samples: 331415
Nr. samples lost due to sample address not in expected range for domain: 0
Nr. lost kernel samples: 0
Nr. samples lost due to sample file open failure: 0
Nr. samples lost due to no permanent mapping: 0
Nr. user context kernel samples lost due to no app info available: 0
Nr. user samples lost due to no app info available: 0
Nr. backtraces skipped due to no file mapping: 0
Nr. hypervisor samples dropped due to address out-of-range: 0
Nr. samples lost reported by perf_events kernel: 0

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM