dbMan/Extension/BenchmarkStop.pm untested

filter: Statementstmt 0.0% 0 / 27 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 45 CC 5 SCAR 23.0
CC
5
Cov
0%
handle_action
20.0
init
6.0
IDENTIFICATION
2.0
CRAP 10.0
1 package DBIx::dbMan::Extension::BenchmarkStop;
2  
3 use strict;
4 use base 'DBIx::dbMan::Extension';
5  
6 our $VERSION = '0.02';
7  
8 1;
9  
10 sub IDENTIFICATION { return "000001-000052-000002"; }
11  
12 sub preference { return -40; }
13  
14 sub init {
15 my $obj = shift;
16  
17 $obj->{hires} = 0;
18 eval q{
19 use Time::HiRes qw/gettimeofday tv_interval/;
20 };
21 ++$obj->{hires} unless $@;
22 }
23  
24 sub handle_action {
25 my ($obj,%action) = @_;
26  
27 if ($action{benchmark_starttime}) {
28 my $time;
29 if ($obj->{hires}) {
30 eval q{
31 $time = tv_interval($action{benchmark_starttime},[ gettimeofday ]);
32 };
33 } else {
34 $time = time-$action{benchmark_starttime};
35 }
36 delete $action{benchmark_starttime};
37 my $info = "Elapsed time: $time s\n";
38 if ($action{action} eq 'OUTPUT') {
39 $action{output} .= $info;
40 } else {
41 $obj->{-interface}->print($info);
42 }
43 }
44  
45 $action{processed} = 1;
46 return %action;
47 }