On Wed 02 Jul 2008 at 03:19PM, Dan Price wrote:
> On Wed 02 Jul 2008 at 02:56PM, Danek Duvall wrote:
> > On Wed, Jul 02, 2008 at 02:46:01PM -0700, Dan Price wrote:
> >
> > > > version.py:
> > > >
> > > > - line 152: do you want to do any further semantic checking on the
> > > > string? That is, months can't be greater than 12, etc?
> > >
> > > Sigh, that's a big problem. My concern is that it's going to be rather
> > > expensive for all the checks we'll need to do. It may be that it winds
> > > up being worth storing the timestamp as an integer, since we'll need to
> > > pay the price to convert to ints during the validity checking.
> >
> > Yup. And conversion from integer to string isn't (or shouldn't be) that
> > expensive.
>
> Indeed.
So to close the loop on this: I worked out that for some, but not
massive, performance hit, we can convert to a pair of ints, then create
a datetime object-- which will validate that the time is valid, and
throw an exception if not. datetime is written in C, so is pretty fast
to construct. Then I just throw away the datetime.
Here's how it breaks out:
Old Code No-Checks With-Checks
fmri-create 21547 52415 (2.4x) 44863 (2.0x)
So no-checks is about 17% faster than with-checks, but that's a hit
we'll just have to live with.
I also tried rewriting my implementation so that I stored the datetime
instead of the string, but it's a bit slower in basically all cases to
do it that way, so I left it as is.
-dp
--
Daniel Price - Solaris Kernel Engineering - [EMAIL PROTECTED] - blogs.sun.com/dp
_______________________________________________
pkg-discuss mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/pkg-discuss