octave-maintainers
[Top][All Lists]
Advanced

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

Re: For loop benchmarks between Octave versions


From: Daniel J Sebald
Subject: Re: For loop benchmarks between Octave versions
Date: Tue, 24 Jun 2014 03:01:36 -0500
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.24) Gecko/20111108 Fedora/3.1.16-1.fc14 Thunderbird/3.1.16

On 06/24/2014 02:04 AM, Julien Bect wrote:

Here are the new results on 3.8.2-RC1:

without patch with patch
doubleForLoop/1 181.8 [ 1.8] 210.2 [ 7.9] evol: +15.6%

Strange one there, but it doesn't matter because such loop isn't to be used in practice.

vectorOfSquares 326.8 [ 4.0] 591.9 [ 2.1] evol: +81.1%

I'm surprised given all that really is being done with this test is populating a memory array:

function vectorOfSquares (nrep, n)

for r = 1:nrep
    x = zeros (1, n);
    for i = 1:n
        x(i) = i * i;
    end
end

end

I guess there is a multiplication there as well, but that's pretty simple too.

In any case, one thing to keep in mind is that the vectorOfSquares tests a for-loop implementation. But a more-likely faster approach would be

function vectorOfSquaresFaster (nrep, n)

for r = 1:nrep
    i = 1:n;
    x = i.*i;
end

end

Just depends on what it is one wants to measure (looping or vector multiplication).

Dan



reply via email to

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