-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build results of a0f2539 (on master)
- Loading branch information
Showing
11 changed files
with
235 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
||
|
||
|
||
|
||
|
||
|