Unix::Getrusage - Perl interface to the Unix getrusage system call
use Unix::Getrusage; my $usage = getrusage; # getrusage(RUSAGE_SELF, ...) print "CPU time: ", $usage->{ru_utime}, "\n";
Both getrusage and getrusage_children (no arguments) return what the getrusage() call returns: ressource utilization of either the calling process or its children. They return hash references (to avoid unneccessary copying) of the rusage struct:
use Unix::Getrusage; use Data::Dumper; my $usage = getrusage; # see above print Data::Dumper->new([$usage])->Dump;
which outputs something like this:
$VAR1 = { 'ru_nivcsw' => '12', 'ru_nvcsw' => '0', ..., 'ru_utime' => '0.104414', 'ru_stime' => '0.008031', 'ru_nsignals' => '0' };
getrusage, getrusage_children
man 2 getrusage
David Kroeber, <dk83@gmx.li>
Copyright (C) 2006 by David Kroeber
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available.
To install Unix::Getrusage, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Unix::Getrusage
CPAN shell
perl -MCPAN -e shell install Unix::Getrusage
For more information on module installation, please visit the detailed CPAN module installation guide.