[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: min function very slow?
From: |
John W. Eaton |
Subject: |
Re: min function very slow? |
Date: |
Sun, 30 Jan 2005 01:55:39 -0600 |
On 30-Jan-2005, Daniel J Sebald <address@hidden> wrote:
| On second thought, your hypothesis seems correct. rand() and randn()
| are similar to max/min, being in the same file. I rewrote the function
| with rand/randn and got similar behavior:
|
| octave:1> [loopt, randt, randnt] = rrt(10000)
| loopt = 0.10696
| randt = 0.36079
| randnt = 0.35501
| octave:2> [loopt, randt, randnt] = rrt(10000)
| loopt = 0.10461
| randt = 0.34843
| randnt = 7.3243
If you get results like this, then I suspect your function is still
computing the time differences incorrectly. Try something like
function [looptime,maxtime,mintime]=mmt(N_loop)
t = zeros(4,1);
k=1
t(k++) = cputime();
for i=1:N_loop
j = i;
end
t(k++) = cputime();
for i=1:N_loop
j = min(i);
end
t(k++) = cputime();
for i=1:N_loop
j = max(i);
end
t(k++) = cputime();
x = diff (t);
looptime = x(1);
maxtime = x(2);
mintime = x(3);
endfunction
Your original function used toc() incorrectly. It always returns the
time since the last call to tic().
jwe
- Re: min function very slow?, (continued)
- Re: min function very slow?, John W. Eaton, 2005/01/30
- Re: min function very slow?, Dmitri A. Sergatskov, 2005/01/30
- Re: min function very slow?, John W. Eaton, 2005/01/30
- Re: min function very slow?, Daniel J Sebald, 2005/01/30
- Re: min function very slow?, Daniel J Sebald, 2005/01/30
- Re: min function very slow?, Daniel J Sebald, 2005/01/30
- Re: min function very slow?,
John W. Eaton <=
Re: min function very slow?, Dmitri A. Sergatskov, 2005/01/30