Added nicer size strings to memleak test
[catagits/Catalyst-Runtime.git] / t / optional / memleak.t
CommitLineData
7c40a30f 1#!perl
2
3use strict;
4use warnings;
5
6use FindBin;
7use lib "$FindBin::Bin/../live/lib";
8
9use Test::More;
10use Catalyst::Test 'TestApp';
11956eee 11eval "use GTop";
7c40a30f 12
13plan skip_all => 'set TEST_MEMLEAK to enable this test'
14 unless $ENV{TEST_MEMLEAK};
15plan skip_all => 'GTop required for this test' if $@;
16
17plan tests => 1;
18
19{
20 # make a request to set initial memory size
21 request('http://localhost');
22
23 my $gtop = GTop->new;
24 my $initial = $gtop->proc_mem($$)->size;
c6294ccd 25 print "Initial Size: " . GTop::size_string($initial) . "\n";
7c40a30f 26
27 for ( 1 .. 1000 ) {
28 request('http://localhost');
29 }
30
31 my $final = $gtop->proc_mem($$)->size;
c6294ccd 32 print "Final Size: " . GTop::size_string($final) . "\n";
7c40a30f 33
34 if ( $final > $initial ) {
c6294ccd 35 print "Leaked Bytes: " . GTop::size_string($final - $initial) . "\n";
7c40a30f 36 }
37
38 is( $final, $initial, 'memory is not leaking' );
39}