Skip to content

Commit

Permalink
Build results of a0f2539 (on master)
Browse files Browse the repository at this point in the history
  • Loading branch information
yanick committed Nov 30, 2010
2 parents 55a6a07 + a0f2539 commit 459eb63
Show file tree
Hide file tree
Showing 11 changed files with 235 additions and 15 deletions.
6 changes: 5 additions & 1 deletion Build.PL
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@ use Module::Build 0.3601;
my %module_build_args = (
'build_requires' => {
'Carp' => '0',
'Catalyst' => '0',
'Catalyst::Controller' => '0',
'Module::Build' => '0.3601',
'Scalar::Util' => '0',
'Test::More' => '0.94',
'Test::WWW::Mechanize::Catalyst' => '0',
'parent' => '0',
'perl' => '5.004'
},
'configure_requires' => {
Expand All @@ -21,7 +25,7 @@ my %module_build_args = (
'Yanick Champoux <yanick@babyl.dyndns.org>'
],
'dist_name' => 'Catalyst-Plugin-MemoryUsage',
'dist_version' => '0.0.1',
'dist_version' => '0.0.2',
'license' => 'perl',
'module_name' => 'Catalyst::Plugin::MemoryUsage',
'recommends' => {},
Expand Down
4 changes: 4 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
Revision history for Catalyst::Plugin::MemoryUsage

0.0.2 2010-11-29 20:41:21 America/Montreal
* Flesh out the documentation a little bit.
* Add a test.

0.0.1 2010-11-28 23:05:10 America/Montreal
* First release on an unsuspecting world.

4 changes: 4 additions & 0 deletions MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ LICENSE
MANIFEST
META.json
META.yml
README
SIGNATURE
lib/Catalyst/Plugin/MemoryUsage.pm
t/000-report-versions.t
t/basic_app.t
t/lib/TestApp.pm
t/lib/TestApp/Controller/Root.pm
8 changes: 6 additions & 2 deletions META.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,20 @@
"test" : {
"requires" : {
"Carp" : 0,
"Catalyst" : 0,
"Catalyst::Controller" : 0,
"Scalar::Util" : 0,
"Test::More" : "0.94",
"Test::WWW::Mechanize::Catalyst" : 0,
"parent" : 0,
"perl" : "5.004"
}
}
},
"provides" : {
"Catalyst::Plugin::MemoryUsage" : {
"file" : "lib/Catalyst/Plugin/MemoryUsage.pm",
"version" : "v0.0.1"
"version" : "v0.0.2"
}
},
"release_status" : "stable",
Expand All @@ -60,6 +64,6 @@
"web" : "http://github.com/yanick/Catalyst-Plugin-MemoryUsage/tree"
}
},
"version" : "0.0.1"
"version" : "0.0.2"
}

8 changes: 6 additions & 2 deletions META.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ author:
- 'Yanick Champoux <yanick@babyl.dyndns.org>'
build_requires:
Carp: 0
Catalyst: 0
Catalyst::Controller: 0
Module::Build: 0.3601
Scalar::Util: 0
Test::More: 0.94
Test::WWW::Mechanize::Catalyst: 0
parent: 0
perl: 5.004
configure_requires:
Module::Build: 0.3601
Expand All @@ -20,7 +24,7 @@ name: Catalyst-Plugin-MemoryUsage
provides:
Catalyst::Plugin::MemoryUsage:
file: lib/Catalyst/Plugin/MemoryUsage.pm
version: v0.0.1
version: v0.0.2
requires:
MRO::Compat: 0
Memory::Usage: 0
Expand All @@ -30,4 +34,4 @@ resources:
bugtracker: http://rt.cpan.org/Public/Dist/Display.html?Name=Catalyst-Plugin-MemoryUsage
homepage: http://search.cpan.org/dist/Catalyst-Plugin-MemoryUsage/
repository: git://github.com/yanick/Catalyst-Plugin-MemoryUsage.git
version: 0.0.1
version: 0.0.2
79 changes: 79 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
NAME
Catalyst::Plugin::MemoryUsage - Profile memory usage of requests

VERSION
version 0.0.2

SYNOPSIS
In YourApp.pm:

package YourApp;

use Catalyst qw/
MemoryUsage
/;

In a Controller class:

sub foo :Path( '/foo' ) {
# ...

something_big_and_scary();

$c->memory_usage->record( 'finished running iffy code' );

# ...
}

DESCRIPTION
"Catalyst::Plugin::MemoryUsage" adds a memory usage profile to your
debugging log, which looks like this:

[debug] memory usage of request
time vsz ( diff) rss ( diff) shared ( diff) code ( diff) data ( diff)
0 45304 ( 45304) 38640 ( 38640) 3448 ( 3448) 1112 ( 1112) 35168 ( 35168) preparing for the request
0 45304 ( 0) 38640 ( 0) 3448 ( 0) 1112 ( 0) 35168 ( 0) after Galuga::Controller::Root : _BEGIN
0 45304 ( 0) 38640 ( 0) 3448 ( 0) 1112 ( 0) 35168 ( 0) after Galuga::Controller::Root : _AUTO
0 46004 ( 700) 39268 ( 628) 3456 ( 8) 1112 ( 0) 35868 ( 700) finished running iffy code
0 46004 ( 0) 39268 ( 0) 3456 ( 0) 1112 ( 0) 35868 ( 0) after Galuga::Controller::Entry : entry/index
0 46004 ( 0) 39268 ( 0) 3456 ( 0) 1112 ( 0) 35868 ( 0) after Galuga::Controller::Root : _ACTION
1 47592 ( 1588) 40860 ( 1592) 3468 ( 12) 1112 ( 0) 37456 ( 1588) after Galuga::View::Mason : Galuga::View::Mason->process
1 47592 ( 0) 40860 ( 0) 3468 ( 0) 1112 ( 0) 37456 ( 0) after Galuga::Controller::Root : end
1 47592 ( 0) 40860 ( 0) 3468 ( 0) 1112 ( 0) 37456 ( 0) after Galuga::Controller::Root : _END
1 47592 ( 0) 40860 ( 0) 3468 ( 0) 1112 ( 0) 37456 ( 0) after Galuga::Controller::Root : _DISPATCH

METHODS
"memory_usage()"
Returns the Memory::Usage object available to the context.

To record more measure points for the memory profiling, use the
"record()" method of that object:

sub foo :Path {
my ( $self, $c) = @_;

...

big_stuff();

$c->memory_usage->record( "done with big_stuff()" );

...
}

"reset_memory_usage()"
Discards the current "Memory::Usage" object, along with its recorded
data, and replaces it by a shiny new one.

SEE ALSO
Memory::Usage

AUTHOR
Yanick Champoux <yanick@babyl.dyndns.org>

COPYRIGHT AND LICENSE
This software is copyright (c) 2010 by Yanick Champoux.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

22 changes: 13 additions & 9 deletions SIGNATURE
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,22 @@ not run its Makefile.PL or Build.PL.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

SHA1 f182551f3493c24f04d526d38c56e4450559364a Build.PL
SHA1 d28653e1d1e57554b16266ade94ed5074bc28e36 Changes
SHA1 0935e08f67f910760c727206242204fd213e8ff9 Build.PL
SHA1 481565171ec6472c0ae3455e7066661dd53f560a Changes
SHA1 3ee0d276167c367325eebe1d5ec9877ade504d93 LICENSE
SHA1 4a250bd13131b21e725f635b4fc19a18819978ca MANIFEST
SHA1 35dd3abaf8fe487772793ed619fbe849225cd3cc META.json
SHA1 889b8fe943a9c9ae2b61d0964a765c05c0013e47 META.yml
SHA1 9d6828f331d7ca6e6c3595cdffd5fc6a05b20ea1 lib/Catalyst/Plugin/MemoryUsage.pm
SHA1 1348feac0c270faaf3dbfbb4a79a719ffdc54ac7 MANIFEST
SHA1 a97a2aafa652ec51429f506679322d11b90c08e3 META.json
SHA1 d1cc5e56e88d17774a58a5df536687bae6375287 META.yml
SHA1 24d74938b3d45d6cc05739cd36fe5741b56807e8 README
SHA1 df705cbb67bb370c5cf620db748c9fcbb0a84dad lib/Catalyst/Plugin/MemoryUsage.pm
SHA1 050aa113e828a52db3c86065c0c0ed50198b7ce8 t/000-report-versions.t
SHA1 889130f3aa95afc8482dfe92777d4f5129f14820 t/basic_app.t
SHA1 579bfe1fb8b92f492eba9a177695e6cc5a6ba3b7 t/lib/TestApp.pm
SHA1 2de5436c98b1ec7e9c43759b94ba0059c027736b t/lib/TestApp/Controller/Root.pm
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iEYEARECAAYFAkzzJnsACgkQ34Hwf+GwC4zvSgCeOjINpKAApdiw8EkRfBuYv2ko
O7UAn0HIZGx6oOmYb7w6QVsGewTXJyIS
=vefF
iEYEARECAAYFAkz0VkgACgkQ34Hwf+GwC4y9+wCfbN738Ic5rLogo5EJLZOLYR9f
BeEAoOtE1PeDnlbfMBnuNoN8/v7D5439
=iJo8
-----END PGP SIGNATURE-----
35 changes: 34 additions & 1 deletion lib/Catalyst/Plugin/MemoryUsage.pm
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ has memory_usage => (
default => sub { Memory::Usage->new },
);


sub reset_memory_usage {
my $self = shift;

Expand Down Expand Up @@ -51,6 +52,8 @@ before finalize => sub {
1;




__END__
=pod
Expand All @@ -60,7 +63,7 @@ Catalyst::Plugin::MemoryUsage - Profile memory usage of requests
=head1 VERSION
version 0.0.1
version 0.0.2
=head1 SYNOPSIS
Expand Down Expand Up @@ -102,6 +105,36 @@ log, which looks like this:
1 47592 ( 0) 40860 ( 0) 3468 ( 0) 1112 ( 0) 37456 ( 0) after Galuga::Controller::Root : _END
1 47592 ( 0) 40860 ( 0) 3468 ( 0) 1112 ( 0) 37456 ( 0) after Galuga::Controller::Root : _DISPATCH
=head1 METHODS
=head2 C<memory_usage()>
Returns the L<Memory::Usage> object available to the context.
To record more measure points for the memory profiling, use the C<record()>
method of that object:
sub foo :Path {
my ( $self, $c) = @_;
...
big_stuff();
$c->memory_usage->record( "done with big_stuff()" );
...
}
=head2 C<reset_memory_usage()>
Discards the current C<Memory::Usage> object, along with its recorded data,
and replaces it by a shiny new one.
=head1 SEE ALSO
L<Memory::Usage>
=head1 AUTHOR
Yanick Champoux <yanick@babyl.dyndns.org>
Expand Down
22 changes: 22 additions & 0 deletions t/basic_app.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

use strict;

use Test::More; # last test to print

use lib 't/lib';

use Test::WWW::Mechanize::Catalyst;
my $mech = Test::WWW::Mechanize::Catalyst->new(catalyst_app => 'TestApp');

$mech->get_ok('/index');

my ( $profile ) = grep { /memory usage/ } @{ $MyLog::mylog->{debug} };

ok $profile, "profile is reported";

like $profile, qr/in the middle of index/, '$c->memory_usage->record() output';

note $profile;

done_testing();

39 changes: 39 additions & 0 deletions t/lib/TestApp.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

package MyLog;

$MyLog::mylog = bless {}, 'MyLog';

sub new {
return $mylog;
}

sub can {
0;
}

sub error {
shift;
push @{ $MyLog::mylog->{error} }, "@_";
}

sub debug {
shift;
push @{ $MyLog::mylog->{debug} }, "@_";
}


package TestApp;

use strict;
use warnings;

use Catalyst qw/ MemoryUsage /;

__PACKAGE__->setup;

sub log {
return MyLog->new;
}


1;
23 changes: 23 additions & 0 deletions t/lib/TestApp/Controller/Root.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package TestApp::Controller::Root;

use strict;
use warnings;

use parent 'Catalyst::Controller';

sub index : Path('/index') {
my ( $self, $c ) = @_;

$c->memory_usage->record( "in the middle of index" );

$c->res->body( 'howdie' );
}


1;






0 comments on commit 459eb63

Please sign in to comment.