0

I need to profile some C++ Mex code.

It is built with G++, using arguments similar to those mex would pass. I can absolutely pass -o0 and -g or -g3, no problem.

The current solutions I have found:

  • MATLAB Profiler - Requires it was built with mex. I tried this myself to no avail. (It provided no information)
  • Visual Studio - Also apparently requires that it was built with mex. I tried this myself with these results sadly. (It just froze)
  • MATLAB Engine - Apparently also requires it was built with mex.
  • Building a C++ driver for it instead of the MATLAB script is likely not an option, as the script is complex and does significant setup (some with other mex files) before the section I want is called.

Is there anything that will work with MEX files not built with mex?

Tyler Shellberg
  • 1,086
  • 11
  • 28
  • You want to profile it with its inside functions or just know how long it takes in general? – Ander Biguri Nov 05 '19 at 16:12
  • It would be best to be able to run the MATLAB script that calls the MEX files, and see what % of the runtime was spent in the C++ code, as well as by function or by line. That's asking a lot, but it would be ideal. Maybe the easiest way is just to wrap the functions in some C-style timing calls and use mexprintf() to print out the time taken. Not fine-grained but perhaps the best that can be done. – Tyler Shellberg Nov 05 '19 at 16:27
  • When using the `mex` script to compile, it calls `g++` or whatever other compiler you have configured. So I don't think that "Requires it was built with `mex`" is correct. Likely, you are not using all the right flags, or you are having a different issue altogether. – Cris Luengo Nov 05 '19 at 17:37
  • @TylerShellberg I am asking because well, `tic; somecppfun();toc;` works – Ander Biguri Nov 05 '19 at 17:43

0 Answers0