Skip Menu |

This queue is for tickets about the Devel-Size CPAN distribution.

Report information
The Basics
Id: 58485
Status: resolved
Priority: 0/
Queue: Devel-Size

People
Owner: Nobody in particular
Requestors: nick [...] ccl4.org
Cc:
AdminCc:

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



Subject: Make Devel::Size include the size of constants in constant subs
Date: Thu, 17 Jun 2010 14:38:17 +0100
To: bug-Devel-Size [...] rt.cpan.org
From: Nicholas Clark <nick [...] ccl4.org>
Building on the patch of RT #58484, here's a patch to make Devel::Size count the size of the constant stored in a constant subroutine. Nicholas Clark --- Size.xs.orig 2010-06-17 14:29:58.000000000 +0100 +++ Size.xs 2010-06-17 14:32:33.000000000 +0100 @@ -547,7 +547,12 @@ UV thing_size(SV *orig_thing, HV *tracki total_size += thing_size((SV *)CvOUTSIDE(thing), tracking_hash); } - if (!CvISXSUB(thing)) { + if (CvISXSUB(thing)) { + SV *sv = cv_const_sv((CV *)thing); + if (sv) { + total_size += thing_size(sv, tracking_hash); + } + } else { if (check_new(tracking_hash, CvSTART(thing))) { total_size += op_size(CvSTART(thing), tracking_hash); } --- t/basic.t.orig 2010-06-17 14:37:34.000000000 +0100 +++ t/basic.t 2010-06-17 14:37:49.000000000 +0100 @@ -94,6 +94,7 @@ isnt (total_size($code), 0, 'total_size( isnt (total_size(\&total_size), 0, 'total_size(\&total_size) > 0'); -use constant LARGE => 'N' x 4096; +use constant LARGE => 'N' x 8192; -isnt (total_size(\&LARGE), 0, 'total_size for a constant > 0'); +cmp_ok (total_size(\&LARGE), '>', 8192, + 'total_size for a constant includes the constant');