[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Significant speed-up of datevec
From: |
Jaroslav Hajek |
Subject: |
Re: Significant speed-up of datevec |
Date: |
Thu, 18 Dec 2008 20:30:50 +0100 |
On Thu, Dec 18, 2008 at 5:33 AM, Daniel J Sebald <address@hidden> wrote:
> Attached is a patch to significantly speed up datevec() in the case that a
> string matrix or string cell is passed in. The ~50 speedup comes simply
> from only deciphering the format string once instead of for every entry in
> the cell/string matrix. Here is a test function:
>
> function DN = testfunc4()
> date1 = '2008-12-16 22:12:00';
> D = repmat(date1, 1000, 1);
> tstart = cputime();
> DN = datenum(D, 'yyyy-mm-dd HH:MM:SS');
> cputime - tstart
> end
>
> and results, without the patch:
>
> octave:1> DN = testfunc4();
> ans = 70.594
>
> with the patch:
>
> octave:1> DN = testfunc4();
> ans = 1.4648
>
> There are probably other little things that could be done to save some time,
> but this gets the bulk of it.
>
> What I don't understand though, is that successively calling this test
> function results in worse performance after the first call:
>
> octave:2> DN = testfunc4();
> ans = 2.1877
> octave:3> DN = testfunc4();
> ans = 2.2437
> ...
>
> Any ideas? (I check the usual suspects, like having to delete the return
> value, etc.)
>
Not really. I have, however, noted that "clear all" prevents the
effect, so I suspect some problem with persistent variables. But it's
definitely worth further investigation.
> Dan
>
I applied this patch. If you intend to make more than a few
contributions to Octave, please consider making yourself familiar with
Mercurial and then using it to create, organize and send patches.
thanks
--
RNDr. Jaroslav Hajek
computing expert
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz