From: Andrew Rodland Date: Thu, 6 Aug 2009 09:57:02 +0000 (+0000) Subject: Add a method to the stats object to get the request start time. X-Git-Tag: 5.80008~39 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=221f7e774f48c96eaa97047bc4c99afd310b54cd Add a method to the stats object to get the request start time. --- diff --git a/lib/Catalyst/Stats.pm b/lib/Catalyst/Stats.pm index 46b5ed4..fd6ec8c 100644 --- a/lib/Catalyst/Stats.pm +++ b/lib/Catalyst/Stats.pm @@ -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 format, with +Unix epoch seconds followed by microseconds. + =head2 elapsed $elapsed = $stats->elapsed diff --git a/t/unit_stats.t b/t/unit_stats.t index 928b48e..676f354 100644 --- a/t/unit_stats.t +++ b/t/unit_stats.t @@ -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;