Skip to content

Instantly share code, notes, and snippets.

@arodland
Created August 6, 2009 09:44
Show Gist options
  • Save arodland/163215 to your computer and use it in GitHub Desktop.
Save arodland/163215 to your computer and use it in GitHub Desktop.
Index: trunk/t/unit_stats.t
===================================================================
--- trunk/t/unit_stats.t (revision 10997)
+++ trunk/t/unit_stats.t (working copy)
@@ -3,7 +3,7 @@
use strict;
use warnings;
-use Test::More tests => 12;
+use Test::More tests => 14;
use Time::HiRes qw/gettimeofday/;
use Tree::Simple;
@@ -19,6 +19,9 @@
my $stats = Catalyst::Stats->new;
is (ref($stats), "Catalyst::Stats", "new");
+ is_deeply(scalar $stats->created, [0, 0], "created arrayref");
+ is(($stats->created)[0], 0, "created list");
+
my @expected; # level, string, time
$fudge_t[0] = 1;
Index: trunk/lib/Catalyst/Stats.pm
===================================================================
--- trunk/lib/Catalyst/Stats.pm (revision 10997)
+++ trunk/lib/Catalyst/Stats.pm (working copy)
@@ -84,6 +84,11 @@
return $node->getUID;
}
+sub created {
+ my $time = shift->{tree}->getNodeValue->{t};
+ return wantarray ? @$time : $time;
+}
+
sub elapsed {
return tv_interval(shift->{tree}->getNodeValue->{t});
}
@@ -297,6 +302,15 @@
Returns the UID of the current point in the profile tree. The UID is
automatically assigned if not explicitly given.
+=head2 created
+
+ $created = $stats->created;
+ ($seconds, $microseconds) = $stats->created;
+
+Returns the time the object was created, in C<gettimeofday> format, with
+Unix epoch seconds followed by microseconds. Returns a list in list context
+or an arrayref in scalar context.
+
=head2 elapsed
$elapsed = $stats->elapsed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment