Benchmark-Timer-Class
view release on metacpan or search on metacpan
110111112113114115116117118119120121122123124125126127128129130# in the first place.
my
$routine
=
$AUTOLOAD
;
# Strip off the package/module stuff at the start
$routine
=~ s/.*:://;
# Dont pass on the DESTROY call
return
if
$routine
eq
'DESTROY'
;
# Create a new Timer object if we dont already have one
if
(!
exists
$self
->{stats}) {
$self
->{stats} = new Benchmark::Timer();
}
# Start the timer, call the routine, then stop the timer.
# Finally return the results to the user.
my
(
$result
,
@results
);
if
(
wantarray
) {
# User called a routine that required an array/hash return value
$self
->{stats}->start(
$routine
);
@results
=
$self
->{timed_class}->
$routine
(
@_
);
$self
->{stats}->stop(
$routine
);
return
@results
;
}
else
{
# User called a routine that required a scalar return value
( run in 0.641 second using v1.01-cache-2.11-cpan-179a2ef0c17 )