Skip Menu |

This queue is for tickets about the Test-Unit CPAN distribution.

Report information
The Basics
Id: 124621
Status: new
Priority: 0/
Queue: Test-Unit

People
Owner: Nobody in particular
Requestors: rowaa [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: [PATCH] Startup is slow in big suites due to get_matching_methods
I have a big test suite in old project with about 6,5k test. When I run a full suite there's a very noticeable 15-20 seconds delay before output even starts ticking. NYTProf shows all this time is spent in get_matching_methods, retrieving all test names for entire suite. Right now it uses Devel::Symdump, that does a lot of extra unnecessary work for this task, like testing each glob for what type it is and wrapping/unwrapping data in module's internal storage. Replacing calls to it with simple loop over symtable and test if found entry is sub reduced this startup delay below 0.5s for me - i.e. over order of magnitude and makes T::U have one less depend. Relevant change to get_matching_methods and accompanying change to a single line with regexp in list_tests in attach
Subject: Test-Unit-TestCase-faster-start.pl
sub list_tests { my $class = ref($_[0]) || $_[0]; my @tests = (); no strict 'refs'; if (@{"$class\::TESTS"}) { push @tests, @{"$class\::TESTS"}; } else { push @tests, $class->get_matching_methods(qr/^test/); } push @tests, map {$_->can('list_tests') ? $_->list_tests : () } @{"$class\::ISA"}; my %tests = map {$_ => ''} @tests; return keys %tests; } sub get_matching_methods { my $class = ref($_[0]) || $_[0]; my $re = $_[1]; no strict 'refs'; my $symtable = *{$class . '::'}; return grep { defined &{$class . '::' . $_} and /$re/ } keys %$symtable; }