1package Unix::Getrusage; 2 3use 5.008006; 4use strict; 5use warnings; 6 7require Exporter; 8use AutoLoader qw(AUTOLOAD); 9 10our @ISA = qw(Exporter); 11 12# Items to export into callers namespace by default. Note: do not export 13# names by default without a very good reason. Use EXPORT_OK instead. 14# Do not simply export all your public functions/methods/constants. 15 16# This allows declaration use Unix::Getrusage ':all'; 17# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK 18# will save memory. 19our %EXPORT_TAGS = ( 'all' => [ qw(getrusage getrusage_children) ] ); 20 21our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); 22 23our @EXPORT = qw(getrusage getrusage_children); 24 25our $VERSION = '0.03'; 26 27require XSLoader; 28XSLoader::load('Unix::Getrusage', $VERSION); 29 30# Preloaded methods go here. 31 32# Autoload methods go after =cut, and are processed by the autosplit program. 33 341; 35__END__ 36# Below is stub documentation for your module. You'd better edit it! 37 38=head1 NAME 39 40Unix::Getrusage - Perl interface to the Unix B<getrusage> system call 41 42=head1 SYNOPSIS 43 44 use Unix::Getrusage; 45 46 my $usage = getrusage; # getrusage(RUSAGE_SELF, ...) 47 print "CPU time: ", $usage->{ru_utime}, "\n"; 48 49=head1 DESCRIPTION 50 51Both I<getrusage> and I<getrusage_children> (no arguments) return what 52the B<getrusage()> call returns: ressource utilization of either the 53calling process or its children. They return hash references (to avoid 54unneccessary copying) of the rusage struct: 55 56 use Unix::Getrusage; 57 use Data::Dumper; 58 59 my $usage = getrusage; # see above 60 print Data::Dumper->new([$usage])->Dump; 61 62which outputs something like this: 63 64 $VAR1 = { 65 'ru_nivcsw' => '12', 66 'ru_nvcsw' => '0', 67 ..., 68 'ru_utime' => '0.104414', 69 'ru_stime' => '0.008031', 70 'ru_nsignals' => '0' 71 }; 72 73=head2 EXPORT 74 75getrusage, getrusage_children 76 77=head1 SEE ALSO 78 79man 2 getrusage 80 81=head1 AUTHOR 82 83David Kroeber, E<lt>dk83@gmx.liE<gt> 84 85=head1 COPYRIGHT AND LICENSE 86 87Copyright (C) 2006 by David Kroeber 88 89This library is free software; you can redistribute it and/or modify 90it under the same terms as Perl itself, either Perl version 5.8.6 or, 91at your option, any later version of Perl 5 you may have available. 92 93 94=cut 95 96# $Id: Getrusage.pm 12 2006-02-04 00:54:08Z taffy $ 97