diff options
author | Yorhel <git@yorhel.nl> | 2009-08-09 10:30:34 +0200 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2009-08-09 10:30:34 +0200 |
commit | 4e000d97b6667daccf21e9f3765428cbba4512b4 (patch) | |
tree | 2c4d31062653f22549530d5c76df6c39bc1f8424 | |
parent | 9095f70cabca29291317a7a33815e7c33bf64b5d (diff) |
Give query execution time as argument to the results function
-rw-r--r-- | lib/POE/Component/Pg.pm | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/POE/Component/Pg.pm b/lib/POE/Component/Pg.pm index 076d4b7..a68966b 100644 --- a/lib/POE/Component/Pg.pm +++ b/lib/POE/Component/Pg.pm @@ -74,6 +74,7 @@ package POE::Component::Pg::STATES; use POE; use DBI; use DBD::Pg ':async'; +use Time::HiRes 'time'; sub QACT { 0 } sub QSESID { 1 } @@ -270,12 +271,13 @@ sub dbi_canread { $res = $_[HEAP]{q}->fetchall_arrayref({}) if $item->[QACT] eq 'query'; }; $_[HEAP]{q} = undef; + my $time = time - $_[HEAP]{querystart}; # send event if($@) { sendevent \@_, 'error', $item->[QACT], $@, $item->[QQUERY], $item->[QPARAM], $item->[QSESID], $item->[QARG]; } elsif($item->[QEVENT]) { - $_[KERNEL]->post($item->[QSESID], $item->[QEVENT], $num, $res, exists $item->[QARG] ? $item->[QARG] : ()); + $_[KERNEL]->post($item->[QSESID], $item->[QEVENT], $num, $res, $item->[QARG], $time); } $_[KERNEL]->refcount_decrement($item->[QSESID], 'P:C:PG') if defined $item->[QSESID]; @@ -288,6 +290,7 @@ sub dbi_canread { sub dbi_canwrite { # execute topmost query in the queue my $item = $_[HEAP]{queue}[0]; + $_[HEAP]{querystart} = time; eval { $_[HEAP]{q} = $_[HEAP]{dbi}->prepare($item->[QQUERY], { pg_async => PG_ASYNC }); $_[HEAP]{q}->execute($item->[QPARAM] && ref($item->[QPARAM]) eq 'ARRAY' ? @{$item->[QPARAM]} : ()); |