1

I have a (C++) program where I need to do some matrix multiplication (small - 3x3 or 6x6 at the most). I'm using OpenCV to do this.

In addition, my program builds and uses a 3D look-up table using standard pointers. I'm wondering if I should use OpenCV to build these as well, or if it would be faster or use less memory to use the standard pointers? Or will it not really matter since I #include the OpenCV headers anyway?

Is it bad programming practice to use both in my program?

asrjarratt
  • 314
  • 6
  • 17
  • 1
    Generally speaking with these performance related questions it's a good idea to benchmark the code for both. Have you tried doing that? – shuttle87 Nov 21 '14 at 16:16
  • @shuttle87 I'm not entirely sure what you mean - I've never done that before. Do you mean just write a program that does both and see what the difference in cpu time is? – asrjarratt Nov 21 '14 at 16:21
  • 2
    I would suggest to ask a profiler how much of the running time is due to the matrix multiplications. It might be just a smaller portion. Often hard to guess which part of the code is taking a lot of time. – tgmath Nov 21 '14 at 16:26
  • 1
    @awilds first look into some profiling tools as tgmath suggested. Callgrind comes to mind, there's other tools too. That will let you find where the program is spending most of its execution time. After you do that, if any only if you find that there's a problem with the performance of a piece of code, benchmark the different alternatives. You want to isolate only that part of the code (or as close to that as possible) then do multiple runs with multiple repetitions. have a look at: http://stackoverflow.com/questions/1861294/how-to-calculate-execution-time-of-a-code-snippet-in-c?rq=1 – shuttle87 Nov 21 '14 at 17:22

0 Answers0