[Catalyst-commits] r11037 - in Catalyst-Runtime/5.80/trunk: lib/Catalyst t

hobbs at dev.catalyst.perl.org hobbs at dev.catalyst.perl.org
Thu Aug 6 09:57:03 GMT 2009


Author: hobbs
Date: 2009-08-06 09:57:02 +0000 (Thu, 06 Aug 2009)
New Revision: 11037

Modified:
   Catalyst-Runtime/5.80/trunk/lib/Catalyst/Stats.pm
   Catalyst-Runtime/5.80/trunk/t/unit_stats.t
Log:
Add a method to the stats object to get the request start time.


Modified: Catalyst-Runtime/5.80/trunk/lib/Catalyst/Stats.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/lib/Catalyst/Stats.pm	2009-08-05 20:08:32 UTC (rev 11036)
+++ Catalyst-Runtime/5.80/trunk/lib/Catalyst/Stats.pm	2009-08-06 09:57:02 UTC (rev 11037)
@@ -84,6 +84,10 @@
     return $node->getUID;
 }
 
+sub created {
+    return @{ shift->{tree}->getNodeValue->{t} };
+}
+
 sub elapsed {
     return tv_interval(shift->{tree}->getNodeValue->{t});
 }
@@ -297,6 +301,13 @@
 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

Modified: Catalyst-Runtime/5.80/trunk/t/unit_stats.t
===================================================================
--- Catalyst-Runtime/5.80/trunk/t/unit_stats.t	2009-08-05 20:08:32 UTC (rev 11036)
+++ Catalyst-Runtime/5.80/trunk/t/unit_stats.t	2009-08-06 09:57:02 UTC (rev 11037)
@@ -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 @@
     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;




More information about the Catalyst-commits mailing list