[Fwd: compare the executive speed with Matlab]
David Bateman
dbateman at dbateman.org
Sun Jan 4 22:21:30 CST 2009
Howard wrote:
> Hi Michael,
>
> Thanks for your time.
>
> For testing non-loop code, I created a simple code with repeating 1000
> 'a=1', as you can see from the attached file. However, I still got the
> result as below:
>
> Octave on Windows
> Elapsed time is 0.005150 seconds.
>
> Matlab on Windows
> Elapsed time is 0.000011 seconds.
>
> Octave on Ubuntu Linux
> Elapsed time is 0.004730 seconds.
>
> The reason I raised this issue because I will check any problem with the
> installation or configuration if Octave must be faster than Matlab.
>
> No offence, I'm just wondering the executive time compared with Matlab.
> I appreciate the open source software and will keep it.
>
That is a completely artificial test, and the difference might still be
due to parser issues and give the speed difference in absolute terms,
the example is irrelevant. What michael meant is take your code like
for i = 0:nSteps
state = i + 1;
St = AssetP * Up ^ i * Down ^ (nSteps - i);
Value(state) = max(0, b * (St - Strike));
end
for tt = nSteps - 1 : -1 : 0
for i = 0:tt
state = i + 1;
Value(state) = (P_up * Value(state + 1) + P_down * Value(state)) * Df;
end
end
and rewrite it as something like
Value = max (0, b * (AsserP .* Up .^ [0:nSteps] .* Down .^ (nSteps - [0:nSteps])
for tt = nSteps - 1 : -1 : 0
Value(1:tt+1) = (P_up .* Value([2:tt+2] + 1) + P_down * Value([1:tt+1])) * Df;
end
Its probably easy to get rid of the last loop too..
D.
> Best regards,
>
> Howard
>
>
>
>
> 於 六,2009-01-03 於 19:36 +0000,Michael Goffioul 提到:
>
>> 2 of your examples use for-loops. Octave if known to be
>> slower than Matlab with for-loops and it has been repeated
>> at many occasions. No wonder about the timing difference.
>> For the 3rd one, I'm not sure, it might be related to the
>> implementation of normcdf function.
>>
>> Michael.
>>
>>
>> On Sat, Jan 3, 2009 at 5:42 PM, Howard <shj1130 at pchome.com.tw> wrote:
>>
>>> Sorry, I forgot to attach the files
>>>
>>> Howard
>>>
>>>
>>> ---------- Forwarded message ----------
>>> From: Howard <shj1130 at pchome.com.tw>
>>> To: help at octave.org
>>> Date: Thu, 01 Jan 2009 18:48:10 +0000
>>> Subject: compare the executive speed with Matlab
>>> Hi Octave,
>>>
>>> I am a new user with Octave 3.0.3. It is very much appreciated of this
>>> good software.
>>>
>>> I'm wondering the executive speed compared with Matlab. I found Octave's
>>> executive time is 10 times slower than Matlab on Windows. (I also try
>>> Octave on Linux, but it is still slower than Matlab on Windows) Some
>>> People discussed this issue on a forum. They said it is because Octave
>>> is not good at Loop code. However, even though I run non-loop code on
>>> Octave and Matlab. Octave's executive time is still much slower than
>>> Matlab.
>>>
>>> Do you think it is normal that Octave's executive speed slower than
>>> Matlab? or it is my configuration's problem?
>>>
>>> Thanks for your time
>>>
>>> Best regards,
>>>
>>> Howard Su
>>>
>>> _______________________________________________
>>> Help-octave mailing list
>>> Help-octave at octave.org
>>> https://www-old.cae.wisc.edu/mailman/listinfo/help-octave
>>>
>>>
>>>
>>> ------------------------------------------------------------------------
>>>
>>> _______________________________________________
>>> Help-octave mailing list
>>> Help-octave at octave.org
>>> https://www-old.cae.wisc.edu/mailman/listinfo/help-octave
--
David Bateman dbateman at dbateman.org
35 rue Gambetta +33 1 46 04 02 18 (Home)
92100 Boulogne-Billancourt FRANCE +33 6 72 01 06 33 (Mob)
More information about the Help-octave
mailing list