[cgiapp] size of scripts and dependencies
Rhesa Rozendaal
perl at rhesa.com
Sat Sep 19 10:15:56 EDT 2009
Richard Jones wrote:
> Ron Savage wrote:
>> Hi Richard
>>
>> On Sat, 2009-09-19 at 10:49 +0100, Richard Jones wrote:
>>> Ron Savage wrote:
>> [snip]
>>> Hi Ron, hey that's nice - I just used it to profile my current app. I
>>> modified it slightly to make it a bit less painful on the eyes (though I
>>
>> You can't be serious. My code may not be perfect, but it's clear what
>> it's doing...
>
> Yep, though I didn't claim mine was either (just personal preferences at
> work here, and the temptation to hack to see what can be done), and the
> use of IO::All in place of manual file handling.
>
> And this also works for me:
>
> $lines += grep { s/^\s+|\s+$//; $_ !~ /^[{}]?$|^#/; } io($_)->chomp->slurp;
>
> though it's still horribly noisy in the grep block (can that be
> improved?), and doesn't exempt content between =begin & =cut blocks.
An approach using PPI would produce more useful results. See
http://search.cpan.org/perldoc?countperl for example.
Here's the output for CGI/Application.pm:
$ countperl /opt/perl/lib/site_perl/5.10.0/CGI/Application.pm
Perl files found: 1
Counts
------
total code lines: 482
lines of non-sub code: 14
packages found: 1
subs/methods: 34
Subroutine/Method Size
----------------------
min: 1 lines
max: 39 lines
mean: 13.76 lines
std. deviation: 9.97
median: 12.00
McCabe Complexity
-----------------
Code not in any subroutine::
min: 1
max 1
mean: 1.00
std. deviation: 0.00
median: 1.00
Subroutines/Methods:
min: 1
max: 16
mean: 4.53
std. deviation: 4.20
median: 3.50
[Tab-delimited list of subroutines omitted]
As you can see, CGI::Application is in good shape with only 482 lines of
actual code, 34 subs or methods, and a good size and complexity per method.
rhesa
More information about the cgiapp
mailing list