help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: speed of octave


From: Don Roberts
Subject: Re: speed of octave
Date: Fri, 7 Sep 2007 09:30:40 -0700

Hi guys;
 
I also ran into an order of magnitude speed difference between Matlab and Octave on a section of >vectorized< (Matlab-style rather than for-loop style code), but don't think it speaks badly of Octave.  The issue does appear to be Matlab's just-in-time >compiler<.  It's been several months and I don't have the exact code handy, but it was an element-wise comparison of two vectors followed by a reduction.  Unfortunately, it's not an apples-to-apples comparison.  Matlab (7.04) was running under XP on a 2.x GHz Pentium and Octave (2.1.73) under Linux under a 2.4 GHz PowerPC.  Re-writing the function as linked-in C gave negligible speed-up for Matlab, but the expected 10X speed-up for Octave.
 
So.... My experience indicates that if you run into something that takes longer than you're willing to wait to run, re-write the offending section in linked-in C and you'll be running about as fast as it can go in Matlab.  And be sure to write your Octave in vectorized Matlab-style code to start with; if there's a for loop you just may have slipped into old habits and are cornering Octave into a slow interpretation rather than a quick optimized-routine call.
 
cheers,
Don Roberts
 
 
----- Original Message -----
Sent: Thursday, September 06, 2007 3:28 PM
Subject: Re: speed of octave

- What arch is this ?
- How many cpu's ?

Also, could it be that Matlab is speeding up the log function ?

Jim

////////////////////////////////

Søren Hauberg wrote:
frank wang skrev:
  
while trying to find the speed of octave, scilab and matlab, I found
the following test code and decided to run it on octave 2.9.13
(window) and matlab 7.1a. The result shows that octave is 30 time
slower than matlab.

in Matlabe: tic; z=bench1(10); toc;
Elapsed time is 0.015060 seconds.

in octave: tic; z=bench1(10); toc;
Elapsed time is 2.704300 seconds.
    
You are working with such a short running program that I think the 
factor 30 is computed very non-robust. But, yes it is true that Octave 
is slower than matlab when working with loops. Matlab comes with a 
Just-in-Time compiler which can speed up the processing of loops quite a 
bit. Octave does not have such a feature. The main issue is that most of 
the people developing Octave aren't the kind of people that enjoy 
writing compilers. So if you know anybody who likes doing that, feel 
free to persuade them to work on a Just-in-time compiler for Octave :-)

Søren


  
function [z]=bench1(n)
for i=1:n,
    for j=1:1000,
        z=log(j);
        z1=log(j+1);
        z2=log(j+2);
        z3=log(j+3);
        z4=log(j+4);
        z5=log(j+5);
        z6=log(j+6);
        z7=log(j+7);
        z8=log(j+8);
        z9=log(j+9);
    end
end
z = z9;

Thanks

Frank
_______________________________________________
Help-octave mailing list
address@hidden
https://www.cae.wisc.edu/mailman/listinfo/help-octave
    
_______________________________________________
Help-octave mailing list
address@hidden
https://www.cae.wisc.edu/mailman/listinfo/help-octave
  


-- 
/////////////////////////////////////////////

Jim Langston
Sun Microsystems, Inc.

(877) 854-5583 (AccessLine)
AIM: jl9594
address@hidden


_______________________________________________
Help-octave mailing list
address@hidden
https://www.cae.wisc.edu/mailman/listinfo/help-octave

reply via email to

[Prev in Thread] Current Thread [Next in Thread]