[Dbix-class] C3 branch is just a tad faster too

John Siracusa siracusa at mindspring.com
Sun Nov 20 06:27:02 CET 2005


Looks like I'm going to have to level the playing field a bit ;)  I've been
letting some apples-to-oranges comparisons slide.

For example, in the "complex" tests, the datetime columns inflate/deflate
to/from DateTime objects.  When it comes to explicitly setting datetime
column values, RDBO will accept and parse string values, then format them as
appropriate for the database.  Some other classes, OTOH, are currently set
to to simply pass values through to the database as-is when they're set
manually.

The whole point of the "complex" cases is to measure efficiency when doing
"DWIMy" stuff like inflate/deflate and parse/format.  But it's hardly fair
for some ORMs to be accepting all sorts of values while some others require
that values already be formatted correctly for the specific database.  The
latter is basically the "simple" case, with no DWIMery.

So, I'll be making those tests more apples-to-apples in the next release.
I'm going to make sure everyone accepts, parses, and formats explicitly set
values instead of doing the reverse (i.e., stopping the other classes from
parsing and formatting explicitly set values) since like I said, that's the
whole point of the "complex" tests.

Unfortunately, I'm not quite sure how best to do that for DBIx::Class.  The
inflate/deflate hooks don't get called at the right times.  I can call the
parsing code on the datetime column args before passing them on to DBIC, but
that's still not quite apples-to-apples since the point is that the ORM is
supposed to do that part in the "complex" tests.

This is the part that's preventing the inflate/deflate hooks from running:

# DBIx/Class/InflateColumn.pm line 73
if(ref $attrs->{$key} && exists $class->column_info($key)->{_inflate_info})

Since the arg is just something like "1/2/2003 12pm" and not an object, the
hooks are skipped.  I can get past it by passing a reference to a scalar and
then dereferencing it in the inflate/deflate hooks, but that's pretty icky.
It also starts to get into the realm of adding substantial code to the
classes, rather than using built-in features.  (Besides, who's going to pass
references to scalars in real code anyway?)  Any better suggestions?

Anyway, even after such adjustments, the latest DBIC is still *much* faster
than it was before.  I didn't do a profile comparison to see if C3 really is
the source of the speed-up, but it sure seems like it.

-John





More information about the Dbix-class mailing list