dbMan/Extension/BenchmarkStart.pm untested

filter: Statementstmt 0.0% 0 / 23 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 50 CC 4 SCAR 17.6
CC
4
Cov
0%
handle_action
12.0
init
6.0
IDENTIFICATION
2.0
CRAP 5.8
1 package DBIx::dbMan::Extension::BenchmarkStart;
2  
3 use strict;
4 use base 'DBIx::dbMan::Extension';
5  
6 our $VERSION = '0.04';
7  
8 1;
9  
10 sub IDENTIFICATION { return "000001-000051-000004"; }
11  
12 sub preference { return 99999; }
13  
14 sub init {
15 my $obj = shift;
16  
17 $obj->{hires} = 0;
18 eval q{
19 use Time::HiRes qw/gettimeofday/;
20 };
21 ++$obj->{hires} unless $@;
22 }
23  
24 sub known_actions { return [ qw/COMMAND/ ]; }
25  
26 sub handle_action {
27 my ($obj,%action) = @_;
28  
29 if ($action{action} eq 'COMMAND' and
30 $obj->{-mempool}->get('benchmark') and
31 not $action{benchmark_starttime}) {
32 if ($obj->{hires}) {
33 eval q{
34 $action{benchmark_starttime} = [ gettimeofday ];
35 };
36 } else {
37 $action{benchmark_starttime} = time;
38 }
39 }
40  
41 $action{processed} = 1;
42 return %action;
43 }