Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compiled MATLAB programs run slow.

Status
Not open for further replies.

Eric27

Computer
Apr 22, 2004
1
Hi all,

I've written a simple function to test the compiler:

function f = test()
tic
for i = 1:10000000
A = 2+5;
B = A/4;
end;
toc

The .m file run in about 0.1 seconds.
After I compile it(mcc -x test.m) the execution time increases to ~3 seconds.
I get the same effect if I compile it to a standalone.
-MATLAB version 6.5.1
-Compiler: Lcc C version 2.4 in C:\MATLAB6P5P1\sys\lcc

I did this after discovering that compiling a rather complex program I had written caused a slowdown.

Any ideas?
 
Replies continue below

Recommended for you

I have the exact same problem using the mcc (a slowdown of approximately 4 times). I ended up rewriting the functions in C and then compiling them into MEX, which resulted in a 50 times speed-up. I'd really appreciate anyone's input on this. Thanks,

Petr
 
I think you are being a little unfair with your test. The original function is badly written matlab code. If you were writing genuine matlab code to perform those 2 operations 10 million times you would write
Code:
function f = test()
tic
A = 2*ones(10000000,1) + 5*ones(10000000,1);
B = A./4;
toc

Matlab is not designed to work quickly with for loops.

M


--
Dr Michael F Platten
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor