octave-bug-tracker
[Top][All Lists]
Advanced

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

[Octave-bug-tracker] [bug #54241] Lookup documentation


From: Michael Leitner
Subject: [Octave-bug-tracker] [bug #54241] Lookup documentation
Date: Wed, 4 Jul 2018 06:46:51 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0

Follow-up Comment #11, bug #54241 (project octave):

Just one point: Octave indeed does handle the case of y=x(1:end-1);
efficiently. Just try the following


a=rand(1e7,1);
b=a;
b=a(2:end);
b=a(1:end-1);


and observe the memory usage while you do that (in the operating system, not
with "whos"). It does not increase, that is, also when assigning subranges
only a reference is stored. 

Your timing is affected by the parsing of the expression. But I think the
point is that we want lookup to be efficient for large y and/or table, while
we do not care for small overheads that apply once per function call. But I
think that my previous conclusions were premature, because:


table=sort(rand(5,1));
y=rand(100000000,1);
tic;for i=1:4 lookup(table(1:5),y);end;toc
Elapsed time is 6.47775 seconds.
tic;for i=1:4 lookup(table(1:4),y);end;toc
Elapsed time is 5.31523 seconds.
tic;for i=1:4 lookup(table(1:5),y,'r');end;toc
Elapsed time is 6.2201 seconds.


So actually what I thought should be faster (looking up into a smaller table)
indeed is faster than looking up into the full table and doing
post-processing. This is something that could be also improved in the code,
making it smaller and executing faster.

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?54241>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

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