Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Speed Comparison
Date: Sat, 11 Apr 2009 00:15:03 +0000 (UTC)
Organization: Boeing
Lines: 10
Message-ID: <grone7$c38$1@fred.mathworks.com>
References: <grokia$rcq$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1239408903 12392 172.30.248.35 (11 Apr 2009 00:15:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sat, 11 Apr 2009 00:15:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 756104
Xref: news.mathworks.com comp.soft-sys.matlab:531966


"Sky " <theskyishigh@yahoo.com> wrote in message <grokia$rcq$1@fred.mathworks.com>...
> I have ported a code from FORTRAN95 to MATLAB. Replicated it almost exactly. About 500 lines in length, it contains a lot of double precision arithmetic and nested iterations. Very little linear algebra.
> 
> Under MATLAB R2008b it executes in 7.3 seconds. Compiled under Compaq Visual Fortran 6 it takes 375 milliseconds. Under the Intel Fortran 11 compiler, it takes 473 MICROseconds. These times are for a WinXP system, Core 2 Duo 2 GHz (4MB L2 Cache), 2GB RAM...
> 
> Is this possible? Is MATLAB this slow or am I doing something wrong?

Yes, it is certainly possible, as you have already demonstrated. Speed comparisons like this are highly dependent on how you did the port and what the MATLAB code is actually doing. There is a potentially a lot of overhead on the MATLAB side that does not exist in the Fortran. E.g., Are you building an array inside a loop without preallocating? Are you manipulating variables in a way that causes a lot of data copying that doesn't exist in the Fortran? Can your nested for-loops in the MATLAB code be vectorized? Etc. etc. Impossible to say if you did anything *wrong* without seeing the code.

James Tursa