octave-maintainers
[Top][All Lists]

## Re: Slowup in 2.1.54

 From: Paul Thomas Subject: Re: Slowup in 2.1.54 Date: Wed, 18 Feb 2004 20:13:36 +0100 User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20030225

```David and Dmitri,

```
Whilst it is a bit at right angles to the discussion because the fault with the [] operator was fixed, should we really worry about constructs like
```
j = 1e 4; tic; x = []; for i=1:j; x = [x, i]; endfor; toc

```
that have square law scaling with the length of i?
```j = 1e4; tic; x = zeros(1, j); for i = 1:j; x(i) = i; endfor; toc

is 30 times faster, at j=1e4, and is linear in j.

Dmitri A. Sergatskov wrote:

```
```David Bateman wrote:

```
```The gcd stuff might just be a timing error. The code used for the timing
in the sciview tests is pretty rough, using tic/toc. I've replaced this
in my version using cputime instead. and get the follow
```
```

cputime does not work with pthreads, so I have to use tic/toc.
Here is another example of recursion slowdown:

2.1.53:

tic; for n=1:1000; bm_x=sylvester_matrix(7) ; endfor ; toc
ans = 4.2025

2.1.54:

tic; for n=1:1000; bm_x=sylvester_matrix(7) ; endfor ; toc
ans = 11.574

(those are both stock releases no patches for SMP/pthreads etc...;
--enable-shared --disable-static ; -O3 -march=athlon-mp; AthlonMP x2)

```
So the only significant slow up I see is in the last test. Here is another
```interting set of tests

2.1.50
tic; x = []; for i=1:1e3; x = [x, i]; endfor; toc ans = 0.079843
tic; x=0; for i=1:1e3; x++; endfor; toc  ans = 0.018920
```
```

```
I do not trust tic/toc numbers less then 0.1 sec. So I increased the index:
```
2.1.53:

tic; x = []; for i=1:1e4; x = [x, i]; endfor; toc
ans = 3.2951

2.1.54:

tic; x = []; for i=1:1e4; x = [x, i]; endfor; toc
ans = 20.234

2.1.53:

tic; x=0; for i=1:1e4; x++; endfor; toc
ans = 0.024073
tic; x=0; for i=1:1e5; x++; endfor; toc
ans = 0.24130
tic; x=0; for i=1:1e6; x++; endfor; toc
ans = 2.3381

2.1.54:

tic; x=0; for i=1:1e4; x++; endfor; toc
ans = 0.028044
tic; x=0; for i=1:1e5; x++; endfor; toc
ans = 0.26263
tic; x=0; for i=1:1e6; x++; endfor; toc
ans = 2.6506

(I do not understand it, but my old records show that loops
were slower, it seems that something else in my system changed that
speeded it up.)

```
```
Regards
David

```
```
Sincerely,
Dmitri.

```
```

```