Ask Your Question
0

Profiling OpenCV using OProfile

asked 2017-01-31 11:16:56 -0600

lovaj gravatar image

updated 2017-01-31 11:17:26 -0600

I have this basic OpenCV program:

#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. I want to profile it using 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?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2017-01-31 18:06:30 -0600

Tetragramm gravatar image

If you're wanting the time it takes, THIS tutorial shows you how to use OpenCV to measure how long operations take. Remember that one iteration is not a good representation of the typical performance. I suggest you run whatever you are profiling many times, (1000 is my usual, less only if it takes a very long time for 1 iteration).

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2017-01-31 11:16:56 -0600

Seen: 364 times

Last updated: Jan 31 '17