-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy path51_plugin_mem_usage.pl
54 lines (36 loc) · 1.06 KB
/
51_plugin_mem_usage.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
use Test::More tests => 3;
BEGIN { use_ok( "EPrints" ); }
BEGIN { use_ok( "EPrints::Test" ); }
our %PLUGIN_MEM_USAGE;
{
package EPrints::Test::PluginFactory;
our @ISA = qw( EPrints::PluginFactory );
sub _load_plugin
{
my( $self, $data, $repository, $fn, $class ) = @_;
EPrints::Test::mem_increase(0); # Reset
my $rc = $self->SUPER::_load_plugin( @_[1..$#_] );
$PLUGIN_MEM_USAGE{$class} = EPrints::Test::mem_increase();
return $rc;
}
}
{
package EPrints::Test::Repository;
our @ISA = qw( EPrints::Repository );
sub _load_plugins
{
my( $self ) = @_;
$self->{plugins} = EPrints::Test::PluginFactory->new( $self );
return defined $self->{plugins};
}
}
my $repository = EPrints::Test::Repository->new( EPrints::Test::get_test_id() );
ok(defined $repository, "test repository creation");
my %usage = %PLUGIN_MEM_USAGE;
my $show = $ENV{PLUGIN_MEM_USAGE} || 5;
diag( "\nPlugin Memory Usage" );
foreach my $class (sort { $usage{$b} <=> $usage{$a} } keys %usage)
{
diag( "$class=".EPrints::Utils::human_filesize( $usage{$class} ) );
last unless --$show;
}