Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Speeding up long-running test suites

8 views
Skip to first unread message

Ovid

unread,
Nov 23, 2007, 12:25:42 PM11/23/07
to per...@perl.org
Hi all,

Test::Class can speed up your your tests by ensuring that perl and
related modules are loaded only once. I was thinking about how this
could be done with normal .t files and a colleague mentioned some stuff
that Apache::Registry does and I thought it would be interesting to see
if I could incorporate its methodology.

I've posted the outline of the idea and the code at
http://www.perlmonks.org/?node_id=652605. It would take some work to
get this production ready, but basically it does the following:

test = ''
foreach .t file:
code = slurp(file)
create a unique package name
test .= <<"END_CODE";
package $package

sub handler {
$code
}
END_CODE
end foerach

eval test
BAILOUT($@) if $@;

foreach package in packages
package->handler
end

Just as with mod_perl, there are caveats on how you can write your
tests:

* no __DATA__ or __END__ blocks.
* Don't rely on implicit behavior of cleanup in END blocks.
* I've had 'use Config' and IPC:: code fail, but I don't know why.

Right now it's just a toy, but my initial work shows that I can gain a
speedup on test suites if they can be run with this. A conceptually
similar idea reduced test time to 1/3rd of its original time.

Cheers,
Ovid

--
Buy the book - http://www.oreilly.com/catalog/perlhks/
Perl and CGI - http://users.easystreet.com/ovid/cgi_course/
Personal blog - http://publius-ovidius.livejournal.com/
Tech blog - http://use.perl.org/~Ovid/journal/

A. Pagaltzis

unread,
Nov 23, 2007, 3:03:35 PM11/23/07
to per...@perl.org
* Ovid <publiuste...@yahoo.com> [2007-11-23 18:30]:

> Test::Class can speed up your your tests by ensuring that perl
> and related modules are loaded only once. I was thinking about
> how this could be done with normal .t files

http://search.cpan.org/dist/PPerl/ ?

--
*AUTOLOAD=*_;sub _{s/(.*)::(.*)/print$2,(",$\/"," ")[defined wantarray]/e;$1}
&Just->another->Perl->hack;
#Aristotle Pagaltzis // <http://plasmasturm.org/>

Ovid

unread,
Nov 25, 2007, 12:01:43 PM11/25/07
to per...@perl.org
--- "A. Pagaltzis" <paga...@gmx.de> wrote:

> * Ovid <publiuste...@yahoo.com> [2007-11-23 18:30]:
> > Test::Class can speed up your your tests by ensuring that perl
> > and related modules are loaded only once. I was thinking about
> > how this could be done with normal .t files
>
> http://search.cpan.org/dist/PPerl/ ?

That often fails to install and internally it forks, giving up much of
the performance benefit I want.

In the meantime, I've just uploaded a proof of concept named
"Test::Aggregate" because it attempts to take a bunch of tests and
aggregate them together.

0 new messages