in reply to Passing a duration time from 1 subroutine to another

I don't know if I understand you correctly, but I'll take a crack.

Are you trying to get cumulative?:

in your test loop (untested)...

$self->{start} = $self->{start} || gettimeofday(): ... # at end of test my $end = gettimeofday(); $self->{duration} += ($end - $self->{start});

Then in your cleanup sub, get the data simply by using $self->{duration}.

If you need a count for each test, keep the existing code, but add at the end:

$self->{tests}{test_name} = $duration;

Then in cleanup, loop over $self->{tests} and extract the duration for each test.

You'll need to fill us in on exactly what you want for us to give a full response.

-stevieb

Replies are listed 'Best First'.
Re^2: Passing a duration time from 1 subroutine to another
by gasjunkie_jabz (Novice) on Aug 25, 2015 at 17:11 UTC

    Thanks Stevie!, I initialized a new attribute called (_duration_time)in my constructor and passed the duration time from the loop into this constructor variable. I am now able to access the duration times in my cleanup sub. Thanks! My new issue now is, I cant get the very first testcase time when I run the testsuite. It gives me a "HASH(0x6c64344)" for the time. All other times are fine. This sounds like there is no time for the first test YET, so it logs the memory data. Is there a way around this?