[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: A faster sum
From: |
Mike Miller |
Subject: |
Re: A faster sum |
Date: |
Sat, 21 May 2005 11:22:41 -0500 (CDT) |
On Sat, 21 May 2005, Keith Goodman wrote:
Most of the time in your examples, I think, is spent in rand. Try moving
that outside of your timing.
You are quite right, Keith. Here are the results:
GNU Octave, version 2.1.50 (i686-pc-linux-gnu).
octave:140> N=1000; X=rand(N,N); t=cputime; ones(1,N)*X; cputime-t
ans = 0.0100000
octave:141> N=2000; X=rand(N,N); t=cputime; ones(1,N)*X; cputime-t
ans = 0.040000
octave:142> N=3000; X=rand(N,N); t=cputime; ones(1,N)*X; cputime-t
ans = 0.090000
octave:143> N=4000; X=rand(N,N); t=cputime; ones(1,N)*X; cputime-t
ans = 0.16000
octave:144> N=5000; X=rand(N,N); t=cputime; ones(1,N)*X; cputime-t
ans = 0.25000
octave:135> N=1000; X=rand(N,N); t=cputime; sum(X); cputime-t
ans = 0.020000
octave:136> N=2000; X=rand(N,N); t=cputime; sum(X); cputime-t
ans = 0.080000
octave:137> N=3000; X=rand(N,N); t=cputime; sum(X); cputime-t
ans = 0.17000
octave:138> N=4000; X=rand(N,N); t=cputime; sum(X); cputime-t
ans = 0.30000
octave:139> N=5000; X=rand(N,N); t=cputime; sum(X); cputime-t
ans = 0.47000
It is clearer now that "sum" takes twice as long as "ones" and that, for
both, CPU times are porportional to n^2.
Why the inconsistency between my results and some of the results reported
by other people? I think my sysadmin installed Octave from an RPM without
a blas. Could that be the difference? Would blas improve "ones" much
more than "sum"?
Anyway, so far, "ones" is a clear winner.
Mike
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------
- A faster sum, Keith Goodman, 2005/05/21
- Re: A faster sum, Victor Eijkhout, 2005/05/21
- Re: A faster sum, Keith Goodman, 2005/05/21
- Re: A faster sum,
Mike Miller <=
- Re: A faster sum, Victor Eijkhout, 2005/05/21
- Re: A faster sum, Keith Goodman, 2005/05/21
- Re: A faster sum, Victor Eijkhout, 2005/05/21
- Re: A faster sum, Mike Miller, 2005/05/21
- Re: A faster sum, John W. Eaton, 2005/05/21