line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Time::TimeTick; |
2
|
|
|
|
|
|
|
|
3
|
7
|
|
|
7
|
|
166479
|
use 5.006; |
|
7
|
|
|
|
|
25
|
|
|
7
|
|
|
|
|
254
|
|
4
|
7
|
|
|
7
|
|
34
|
use strict; |
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
218
|
|
5
|
7
|
|
|
7
|
|
32
|
use warnings; |
|
7
|
|
|
|
|
24
|
|
|
7
|
|
|
|
|
278
|
|
6
|
7
|
|
|
7
|
|
30
|
use Exporter; |
|
7
|
|
|
|
|
9
|
|
|
7
|
|
|
|
|
260
|
|
7
|
7
|
|
|
7
|
|
40
|
use File::Basename; |
|
7
|
|
|
|
|
11
|
|
|
7
|
|
|
|
|
2599
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
10
|
|
|
|
|
|
|
our @EXPORT = qw(timetick); # Although we override Exporter's import() |
11
|
|
|
|
|
|
|
our $VERSION = '0.06'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my @Tix; # Where we keep the time ticks |
14
|
|
|
|
|
|
|
our %Opt; # Global option setting interface |
15
|
|
|
|
|
|
|
my $Epoch = $^T; # Point from which times are measured |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub import |
18
|
|
|
|
|
|
|
{ |
19
|
6
|
|
|
6
|
|
46
|
my $class = shift; |
20
|
6
|
|
|
|
|
21
|
%Opt = @_; |
21
|
|
|
|
|
|
|
|
22
|
6
|
|
|
|
|
49
|
eval { require Time::HiRes }; |
|
6
|
|
|
|
|
5595
|
|
23
|
6
|
50
|
|
|
|
10826
|
$Epoch = _current_time() if $Opt{reset_start}; |
24
|
|
|
|
|
|
|
|
25
|
6
|
100
|
|
|
|
24
|
unless ($Opt{suppress_initial}) |
26
|
|
|
|
|
|
|
{ |
27
|
3
|
|
|
|
|
183
|
my $prog = basename($0); |
28
|
3
|
|
66
|
|
|
21
|
timetick($Opt{initial_tag} || "Timeticker for $prog starting"); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
6
|
|
|
|
|
8961
|
$class->export_to_level(1, @EXPORT); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub unimport |
36
|
|
|
|
|
|
|
{ |
37
|
1
|
|
|
1
|
|
8
|
my $class = shift; |
38
|
1
|
|
|
|
|
3
|
%Opt = @_; |
39
|
7
|
|
|
7
|
|
37
|
no warnings 'redefine'; |
|
7
|
|
|
|
|
12
|
|
|
7
|
|
|
|
|
2429
|
|
40
|
1
|
|
|
2
|
|
18
|
*timetick = sub { }; |
|
2
|
|
|
|
|
11
|
|
41
|
1
|
|
|
|
|
1627
|
$class->export_to_level(1, @EXPORT); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub timetick |
46
|
|
|
|
|
|
|
{ |
47
|
14
|
|
|
14
|
1
|
1000637
|
my $tag = pop; |
48
|
14
|
50
|
|
|
|
64
|
$Opt{format_tick_tag} and $tag = $Opt{format_tick_tag}->($tag); |
49
|
14
|
|
|
|
|
46
|
push @Tix, [ _current_time() - $Epoch, $tag ]; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub _current_time |
54
|
|
|
|
|
|
|
{ |
55
|
14
|
50
|
|
14
|
|
220
|
exists &Time::HiRes::time ? Time::HiRes::time() : time; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub report |
60
|
|
|
|
|
|
|
{ |
61
|
12
|
100
|
|
12
|
1
|
65
|
unless ($Opt{suppress_report}) |
62
|
|
|
|
|
|
|
{ |
63
|
10
|
100
|
|
|
|
24
|
&{ $Opt{format_report} || \&_format_report }(@Tix); |
|
10
|
|
|
|
|
67
|
|
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
12
|
|
|
|
|
82
|
@Tix = (); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub _format_report |
71
|
|
|
|
|
|
|
{ |
72
|
1
|
|
|
1
|
|
392
|
printf("%7.4f %s\n", @$_) for @_; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub end |
77
|
|
|
|
|
|
|
{ |
78
|
8
|
100
|
|
8
|
1
|
46
|
unless ($Opt{suppress_final}) |
79
|
|
|
|
|
|
|
{ |
80
|
5
|
|
|
|
|
224
|
my $prog = basename($0); |
81
|
5
|
|
66
|
|
|
35
|
timetick($Opt{final_tag} || "Timeticker for $prog finishing"); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
8
|
|
|
|
|
24
|
report(); |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
|
88
|
7
|
|
|
7
|
|
6924
|
END { end() } |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
1; |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
__END__ |