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

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

[Octave-bug-tracker] [bug #47627] datenum input validation should be str


From: Rik
Subject: [Octave-bug-tracker] [bug #47627] datenum input validation should be stricter
Date: Fri, 14 Jan 2022 14:10:28 -0500 (EST)
User-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36

Follow-up Comment #25, bug #47627 (project octave):

I like the extra warning.

The function ismember() is pretty slow as it has to do a lot of set-up work
before using a compiled function like lookup().  I think a better alternative
here is strchr().  I made a little benchmarking script shown below.


N = 1e4;

f = "YYYY-MM-DD HH:MM";

tic;
for i = 1:N
  #tf = any (ismember (f, "hsfYD"));
  tf = ! isempty (strchr (f, "hsfYD"));
endfor
toc


Results
ismember : 1.8 seconds
strchr   : 0.8 seconds

It's more than a factor of 2 faster so I think that is a useful change to
make.

On the warning ID, the overall namespace is "Octave" and the next lower
namespace is usually the name of the function.  I would propose
"Octave:datevec:date-format-spec" as the warning ID.

I also thought it useful to have some BIST tests for the new warning ID.

I put all of these ideas into this changeset:
http://hg.savannah.gnu.org/hgweb/octave/rev/c7a515aa767e.




octave:2> exit


    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?47627>

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




reply via email to

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