[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
speed of octave interpreter
From: |
Brian Blais |
Subject: |
speed of octave interpreter |
Date: |
Sun, 25 Sep 2005 13:35:23 -0400 |
User-agent: |
Mozilla Thunderbird 1.0.6 (X11/20050716) |
Hello,
I am running Octave (2.1.71) on Linux (SuSe 9.1), and have written a
simple recursive minimax example for a class, and it seemed to run very
slowly. So, on a whim, I decided to test it in Scilab 3.0, Matlab 7.0
and Octave. In summary, the octave version is about 100x slower. What
I get is the following:
Scilab 3.0:
-->dt=getdate(); nim_minimax(15); etime(getdate(),dt)
ans =
0.648
Matlab 7.0:
>> tic; nim_minimax_matlab(15); toc
Elapsed time is 0.821107 seconds.
Octave 2.1.71
>> tic; nim_minimax(15); toc
ans = 64.208
I am attaching the code, in case anyone else wants to try it. Is there
a reason why the interpreter is more than 100x slower than the others?!
I knew of the problems in Windows, but this is not that problem. Is
there a way to address this, because in some cases it makes the
difference between usable and not usable.
If anyone needs any other info about the system or octave version I am
running, please just ask.
Brian Blais
--
-----------------
address@hidden
http://web.bryant.edu/~bblais
nim_minimax.m
Description: application/octave
function s=nim_minimax(N)
states=get_states(N);
val=evalfunction_minimax(states);
which_state=findmax(val);
new_state=states(which_state);
s=N-new_state;
endfunction
function s=perfect_eval_minimax(N)
states=get_states(N);
val=evalfunction_minimax(states);
which_state=findmax(val);
new_state=states(which_state);
s=N-new_state;
endfunction
function idx=findmax(val)
[junk,idx]=max(val);
endfunction
function v=evalfunction_minimax(s)
for i=1:length(s)
v(i)=minvalue(s(i));
end
endfunction
function maxval=maxvalue(N)
if (game_end(N)) // bad for max
maxval=-1;
return;
end
states=get_states(N);
v=zeros(states);
for i=1:length(states)
v(i)=minvalue(states(i));
end
maxval=max(v);
endfunction
function minval=minvalue(N)
if (game_end(N)) // bad for min
minval=1;
return;
end
states=get_states(N);
v=zeros(states);
for i=1:length(states)
v(i)=maxvalue(states(i));
end
minval=min(v);
endfunction
function tf=game_end(n)
tf=(n<2);
endfunction
function s=get_states(N)
if (N==1)
s=[];
elseif (N==2)
s=[1];
elseif (N==3)
s=[2 1];
else
s=[N-1 N-2 N-3];
end
endfunction
nim_minimax_matlab.m
Description: application/octave
- speed of octave interpreter,
Brian Blais <=
- Re: speed of octave interpreter, Robert A. Macy, 2005/09/25
- Re: speed of octave interpreter, Stefan van der Walt, 2005/09/25
- Re: speed of octave interpreter, Brian Blais, 2005/09/25
- Re: speed of octave interpreter, Robert A. Macy, 2005/09/25
- Re: speed of octave interpreter, John W. Eaton, 2005/09/26
- Re: speed of octave interpreter, Mike Miller, 2005/09/26
- Re: speed of octave interpreter, Robert A. Macy, 2005/09/26
- Re: speed of octave interpreter, Mike Miller, 2005/09/26
- Message not available
- Message not available
- Re: speed of octave interpreter, David Bateman, 2005/09/27
- Re: speed of octave interpreter, Paul Thomas, 2005/09/27