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:
- How do I now which shared library calls
cv::imread
? - 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 editingCMakeLists.txt
with:
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g")
But I don't know where to set it in CMakeLists.txt