File Coverage

blib/lib/Mail/SpamAssassin/Util/ScopedTimer.pm
Criterion Covered Total %
statement 9 16 56.2
branch 0 2 0.0
condition 0 3 0.0
subroutine 3 5 60.0
pod 0 1 0.0
total 12 27 44.4


line stmt bran cond sub pod time code
1             # Helper code to debug dependencies and their versions.
2              
3             # <@LICENSE>
4             # Licensed to the Apache Software Foundation (ASF) under one or more
5             # contributor license agreements. See the NOTICE file distributed with
6             # this work for additional information regarding copyright ownership.
7             # The ASF licenses this file to you under the Apache License, Version 2.0
8             # (the "License"); you may not use this file except in compliance with
9             # the License. You may obtain a copy of the License at:
10             #
11             # http://www.apache.org/licenses/LICENSE-2.0
12             #
13             # Unless required by applicable law or agreed to in writing, software
14             # distributed under the License is distributed on an "AS IS" BASIS,
15             # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16             # See the License for the specific language governing permissions and
17             # limitations under the License.
18             # </@LICENSE>
19              
20              
21             use strict;
22 41     41   294 use warnings;
  41         104  
  41         1302  
23 41     41   233 # use bytes;
  41         94  
  41         1323  
24             use re 'taint';
25 41     41   247  
  41         89  
  41         6182  
26             our @ISA = qw();
27              
28             my $class = shift;
29             my $self = {
30 0     0 0   main => shift,
31 0           timer => shift,
32             };
33             $self->{main}->timer_start($self->{timer});
34             return bless ($self, $class);
35 0           }
36 0            
37             # OO hack: when the object goes out of scope, the timer ends. neat!
38             my $self = shift;
39             # best practices: prevent potential calls to eval and to system routines
40             # in code of a DESTROY method from clobbering global variables $@ and $!
41 0     0     local($@,$!); # keep outer error handling unaffected by DESTROY
42             $self->{main} && $self->{timer} && $self->{main}->timer_end($self->{timer});
43             }
44 0            
45 0 0 0       1;