"Fossies" - the Fresh Open Source Software Archive

Member "eprints3.4-3.4.4/tests/51_plugin_mem_usage.pl" (7 Aug 2022, 1983 Bytes) of package /linux/www/eprints3.4-3.4.4.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "51_plugin_mem_usage.pl": 3.4-3.4.3_vs_3.4-3.4.4.

    1 =head1 NAME
    2 
    3 EPrints::Test::PluginFactory
    4 
    5 =cut
    6 
    7 use Test::More tests => 3;
    8 
    9 BEGIN { use_ok( "EPrints" ); }
   10 BEGIN { use_ok( "EPrints::Test" ); }
   11 
   12 our %PLUGIN_MEM_USAGE;
   13 
   14 {
   15 package EPrints::Test::PluginFactory;
   16 
   17 our @ISA = qw( EPrints::PluginFactory );
   18 
   19     sub _load_plugin
   20     {
   21         my( $self, $data, $repository, $fn, $class ) = @_;
   22 
   23         EPrints::Test::mem_increase(0); # Reset
   24 
   25         my $rc = $self->SUPER::_load_plugin( @_[1..$#_] );
   26 
   27         $PLUGIN_MEM_USAGE{$class} = EPrints::Test::mem_increase();
   28 
   29         return $rc;
   30     }
   31 }
   32 {
   33 package EPrints::Test::Repository;
   34 
   35 our @ISA = qw( EPrints::Repository );
   36 
   37     sub _load_plugins
   38     {
   39         my( $self ) = @_;
   40 
   41         $self->{plugins} = EPrints::Test::PluginFactory->new( $self );
   42 
   43         return defined $self->{plugins};
   44     }
   45 }
   46 
   47 my $repository = EPrints::Test::Repository->new( EPrints::Test::get_test_id() );
   48 
   49 ok(defined $repository, "test repository creation");
   50 
   51 my %usage = %PLUGIN_MEM_USAGE;
   52 
   53 my $show = $ENV{PLUGIN_MEM_USAGE} || 5;
   54 
   55 diag( "\nPlugin Memory Usage" );
   56 foreach my $class (sort { $usage{$b} <=> $usage{$a} } keys %usage)
   57 {
   58     diag( "$class=".EPrints::Utils::human_filesize( $usage{$class} ) );
   59     last unless --$show;
   60 }
   61 
   62 =head1 COPYRIGHT
   63 
   64 =for COPYRIGHT BEGIN
   65 
   66 Copyright 2022 University of Southampton.
   67 EPrints 3.4 is supplied by EPrints Services.
   68 
   69 http://www.eprints.org/eprints-3.4/
   70 
   71 =for COPYRIGHT END
   72 
   73 =for LICENSE BEGIN
   74 
   75 This file is part of EPrints 3.4 L<http://www.eprints.org/>.
   76 
   77 EPrints 3.4 and this file are released under the terms of the
   78 GNU Lesser General Public License version 3 as published by
   79 the Free Software Foundation unless otherwise stated.
   80 
   81 EPrints 3.4 is distributed in the hope that it will be useful,
   82 but WITHOUT ANY WARRANTY; without even the implied warranty of
   83 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
   84 See the GNU Lesser General Public License for more details.
   85 
   86 You should have received a copy of the GNU Lesser General Public
   87 License along with EPrints 3.4.
   88 If not, see L<http://www.gnu.org/licenses/>.
   89 
   90 =for LICENSE END
   91