1

I have this basic OpenCV code:

#include "opencv2/opencv.hpp"

int main(){
    cv::Mat img = cv::imread("/home/luca/Documents/IMG_20161031_162242.jpg", cv::IMREAD_GRAYSCALE);
    if(!img.data)
        std::cerr<<"Error reading image"<<std::endl;
    return 0;
}

I want to profile it to make cv::imread parallel (and try to do the same with many other functions.

Reading this article, what I should do for time profiling a shared-library (as opencv in my case) I should:

1) Compile your shared library (libmylib.so) in debug (-g) mode. No -pg. 2) export LD_PROFILE_OUTPUT=pwd 3) export LD_PROFILE=libmylib.so 4) rm -f $LD_PROFILE.profile 4) execute your program that loads libmylib.so 5) sprof PATH-TO-LIB/$LD_PROFILE $LD_PROFILE.profile -p >log 6) See the log.

I have some questions:

  1. How do I now which shared library calls cv::imread?
  2. I don't know if cmake -DCMAKE_BUILD_TYPE=DEBUG ... includes -g (actually I don't think so). Reading here I could do this by editing CMakeLists.txt with:

set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g")

But I don't know where to set it in CMakeLists.txt

Community
  • 1
  • 1
justHelloWorld
  • 6,478
  • 8
  • 58
  • 138
  • 'Debug' usually implies compiling with debug information, that is `-g` is normally included in that configuration. `How do I now which shared library calls cv::imread?` - Do you mean which library **defines** `cv::imread`? It is your executable which *calls* the function. – Tsyvarev Jan 31 '17 at 07:11
  • @Tsyvarev thanks for your comment. Yes, I mean how do I know which library defines a certain function (it was 2am when I've posted the question :) ) – justHelloWorld Jan 31 '17 at 10:36
  • have You tried [nm](https://sourceware.org/binutils/docs/binutils/nm.html)? – Kamiccolo Feb 02 '17 at 12:44

0 Answers0