octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Fwd: [OctDev] slow structs]


From: John W. Eaton
Subject: [Fwd: [OctDev] slow structs]
Date: Wed, 17 Dec 2008 22:52:09 -0500

On 17-Dec-2008, Daniel J Sebald wrote:

| Subject: [OctDev] slow structs
| Date: Wed, 17 Dec 2008 18:13:17 -0600
| From: Jonathan Kotta <address@hidden>
| To: address@hidden
| 
| I have a problem where a vector within a struct is much slower to
| index than a plain vector (~8x slower) .
| 
| x = zeros(1e6,1);
| s.x = x;
| subset = 500e3:600e3-1;
| y = randn(length(subset),1);
| for i = 1:5
|    tic; x(subset) = y; toc;
| end
| for i = 1:5
|    tic; s.x(subset) = y; toc;
| end

Accessing a structure element requires looking up the element in a map
using the field name (a character string).  You don't expect that
would be free, do you?

jwe


reply via email to

[Prev in Thread] Current Thread [Next in Thread]