Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

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

Report information
The Basics
Id: 55191
Status: resolved
Priority: 0/
Queue: Test-Deep

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

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



Subject: PATCH: cmp_deeply() 6x speedup on large arrays of strings
This patch speeds up cmp_deeply() on large data structures in which most elements are non-references in both the got and expected structures. For me it gives a factor of 6 speedup for cmp_deeply() on identical arrays of 50_000 strings.t
Subject: patch.txt
diff -NrdU5 Test-Deep-0.106.orig/lib/Test/Deep.pm Test-Deep-0.106/lib/Test/Deep.pm --- Test-Deep-0.106.orig/lib/Test/Deep.pm 2009-08-09 22:09:08.000000000 +0200 +++ Test-Deep-0.106/lib/Test/Deep.pm 2010-03-03 21:01:53.000000000 +0200 @@ -254,10 +254,23 @@ sub descend { my ($d1, $d2) = @_; + if (!ref $d1 and !ref $d2) + { + # Shortcut comparison for the non-reference case. + if (defined $d1) + { + return 1 if defined $d2 and $d1 eq $d2; + } + else + { + return 1 if !defined $d2; + } + } + if (! $Expects and ref($d1) and UNIVERSAL::isa($d1, "Test::Deep::Cmp")) { my $where = $Stack->render('$data'); confess "Found a special comparison in $where\nYou can only the specials in the expects structure"; }
Subject: Re: [rt.cpan.org #55191] PATCH: cmp_deeply() 6x speedup on large arrays of strings
Date: Wed, 3 Mar 2010 22:03:54 +0000
To: bug-Test-Deep [...] rt.cpan.org
From: Fergal Daly <fergal [...] esatclear.ie>
Thanks. I'm pretty sure this code was in here before but I took it out to make the whole thing uniform as I didn't expect performance to be a requirement. I'll patch this in and release shortly, F
Thanks, applied in git to be released in 0.171 -- rjbs