Relying more on Mouse

Michael G Schwern <[email protected]>
Newsgroups gmane.comp.lang.perl.quality-assurance
Message-ID <[email protected]>
Test::Builder1.5 is slow.  How slow?  About 3x slower than 0.98.  Enough to
significantly impact test performance.  For example, Spiffy takes 1 second
with 0.98 vs 3.3s with 1.5.

I deliberately didn't do any profiling or optimization while the design was
coming together.  This avoided spending time optimizing something that might
just be thrown out, and it focused on getting things working.  And while my
policy has always been that performance is not a priority, a 3x drop is
unacceptable.

    use Test::More;

    pass() for 1..10000;

    done_testing;

0.98
real	0m0.747s
user	0m0.726s
sys	0m0.019s

1.5
real	0m2.301s
user	0m2.271s
sys	0m0.027s

One thing which I know for sure is slowing things down is its use of a pure
Perl Mouse::Tiny.  Test::Builder1.5 has a copy of Mouse::Tiny bundled as
TB2::Mouse.  This both avoids a dependency on Mouse and protects Test::Builder
against Mouse bugs.

Test::Builder 0.98's performance benefits from being a monolithic object which
can quickly grab at it's own guts.  Test::Builder1.5 is well factored out into
objects with attribute accessors.  Pure Perl accessors can't compete with hash
lookups.

But Mouse boosted with XS can.

1.5-gonzales
real	0m1.702s
user	0m1.675s
sys	0m0.025s

Just switching over to my installed Mouse with XS shaved off a big chunk of
the runtime.  Enough that I'm confident profiling can knock off the rest,
there's a lot of easy fat in there.  I've already lopped it down to 1.368s
with two small changes.

The idea would be to continue to ship a copy of Mouse::Tiny as TB2::Mouse,
that takes care of the dependency loop, but to only use it if a good enough
version of Mouse is not already installed.

To mitigate risk of a new version of Mouse breaking Test::Builder, I'd ask the
Mouse folks to test their releases against Test::Builder1.5.  I think they're
already doing that.

Thoughts?


-- 
60. "The Giant Space Ants" are not at the top of my chain of command.
    -- The 213 Things Skippy Is No Longer Allowed To Do In The U.S. Army
           http://skippyslist.com/list/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.