×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Compiled MATLAB programs run slow.

Compiled MATLAB programs run slow.

Compiled MATLAB programs run slow.

(OP)
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?

RE: Compiled MATLAB programs run slow.

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

RE: Compiled MATLAB programs run slow.

I'm convinced MATLAB is just slow

RE: Compiled MATLAB programs run slow.

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources