Add a method to the stats object to get the request start time.
Andrew Rodland [Thu, 6 Aug 2009 09:57:02 +0000 (09:57 +0000)]
lib/Catalyst/Stats.pm
t/unit_stats.t

index 46b5ed4..fd6ec8c 100644 (file)
@@ -84,6 +84,10 @@ sub profile {
     return $node->getUID;
 }
 
+sub created {
+    return @{ shift->{tree}->getNodeValue->{t} };
+}
+
 sub elapsed {
     return tv_interval(shift->{tree}->getNodeValue->{t});
 }
@@ -297,6 +301,13 @@ The profiling point will be ignored if the UID has not been previously defined.
 Returns the UID of the current point in the profile tree.  The UID is
 automatically assigned if not explicitly given.
 
+=head2 created
+
+    ($seconds, $microseconds) = $stats->created;
+
+Returns the time the object was created, in C<gettimeofday> format, with
+Unix epoch seconds followed by microseconds.
+
 =head2 elapsed
 
     $elapsed = $stats->elapsed
index 928b48e..676f354 100644 (file)
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 12;
+use Test::More tests => 13;
 use Time::HiRes qw/gettimeofday/;
 use Tree::Simple;
 
@@ -19,6 +19,8 @@ BEGIN { use_ok("Catalyst::Stats") };
     my $stats = Catalyst::Stats->new;
     is (ref($stats), "Catalyst::Stats", "new");
 
+    is_deeply([ $stats->created ], [0, 0], "created time");
+
     my @expected; # level, string, time
 
     $fudge_t[0] = 1;