Quick update, I wanted to try the matlab vs c++ routines again, because from what I can remember, matlab was several orders of magnitude quicker than the c++ program. But I recently found a library in Qt called QVector, which claims to be very quick on the
whole memory front. So I went back and did the test again. (Because for some reason I didnt leave any trail of documentation like I normally do?)
Now notice my shock, suprise and glee when I rewrote the program for Qt 4, put it in release mode instead of debug and opened a large can of groinal kickers on matlab. See the results below.
Programs, settings, etc. __________________________________
Matlab V7.3 (2006b)
Qt V4.3.4 (release mode, default optimisations, single threading, pure c++ (no QVectors etc.)
MATLAB_____________________________________________
x = -0.5; y = -0.24; hydrophoneDepth = -0.3; SoS = 1482; hydrophoneSpacing = 0.5;
T = [1000000*sqrt( x^2 + (y-hydrophoneSpacing)^2 + hydrophoneDepth^2 )/SoS;
1000000*sqrt( (x-hydrophoneSpacing)^2 + y^2 + hydrophoneDepth^2 )/SoS;
1000000*sqrt( x^2 + (y+hydrophoneSpacing)^2 + hydrophoneDepth^2 )/SoS;
1000000*sqrt( (x+hydrophoneSpacing)^2 + y^2 + hydrophoneDepth^2 )/SoS];
tic
for(x = 1:1000000)
SolvePosition(T,hydrophoneSpacing,hydrophoneDepth,SoS);
end
toc
tic
for(x = 1:1000000)
SolvePosition(T,hydrophoneSpacing,hydrophoneDepth,SoS);
end
toc
tic
for(x = 1:1000000)
SolvePosition(T,hydrophoneSpacing,hydrophoneDepth,SoS);
end
toc
tic
for(x = 1:1000000)
SolvePosition(T,hydrophoneSpacing,hydrophoneDepth,SoS);
end
tocElapsed time is 18.844249 seconds.
Elapsed time is 18.670732 seconds.
Elapsed time is 18.662103 seconds.
Elapsed time is 18.620391 seconds.
c++_____________________________________________
Starting Test
___Position Solve Speed Test___
This routine tests the speed of c++ vs.
Matlab for our developed Multilateration Algorithm
7015Starting Test
___Position Solve Speed Test___
This routine tests the speed of c++ vs.
Matlab for our developed Multilateration Algorithm
6985Starting Test
___Position Solve Speed Test___
This routine tests the speed of c++ vs.
Matlab for our developed Multilateration Algorithm
6969Starting Test
___Position Solve Speed Test___
This routine tests the speed of c++ vs.
Matlab for our developed Multilateration Algorithm
6984
Note that the c++ program is in ms. It is clear to see that there is a clear speed advantage, not a lot I know, but it is clear. There is also more scope for firstly optimising my code specifically for c++, using more aggressive optimisations in the compiler and also using the fast access libraries included in Qt.
Post a Comment