line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MooX::CalcTime::Role; |
2
|
2
|
|
|
2
|
|
12766
|
use Modern::Perl; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
13
|
|
3
|
2
|
|
|
2
|
|
221
|
use Moo::Role; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
9
|
|
4
|
2
|
|
|
2
|
|
1929
|
use DateTime; |
|
2
|
|
|
|
|
156906
|
|
|
2
|
|
|
|
|
505
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.0.6'; # VERSION |
7
|
|
|
|
|
|
|
# ABSTRACT: calculate total time that a program run |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has _time_start => ( |
11
|
|
|
|
|
|
|
is => 'ro', |
12
|
|
|
|
|
|
|
default => time, |
13
|
|
|
|
|
|
|
); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub get_run_second { |
17
|
0
|
|
|
0
|
1
|
|
time - $_[0]->_time_start; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub get_runtime { |
22
|
0
|
|
|
0
|
1
|
|
my $interval = $_[0]->get_run_second; |
23
|
0
|
|
|
|
|
|
my $second = $interval % 60; |
24
|
0
|
|
|
|
|
|
my $total_minute = int ($interval / 60); |
25
|
0
|
|
|
|
|
|
my $minute = $total_minute % 60; |
26
|
0
|
|
|
|
|
|
my $total_hour = int ($total_minute / 60); |
27
|
0
|
|
|
|
|
|
my $hour = $total_hour % 60; |
28
|
0
|
|
|
|
|
|
my $day = int($total_hour / 24); |
29
|
0
|
|
|
|
|
|
my $start = DateTime->from_epoch(epoch => $_[0]->_time_start); |
30
|
0
|
|
|
|
|
|
my $end = DateTime->now; |
31
|
0
|
|
|
|
|
|
my $msg = "Starting time: $start\n"; |
32
|
0
|
|
|
|
|
|
$msg .= "Ending time: $end\n"; |
33
|
0
|
|
|
|
|
|
$msg .= "Running time: $day days $hour hours $minute minutes $second second\n"; |
34
|
0
|
|
|
|
|
|
return $msg; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub print_runtime { |
39
|
0
|
|
|
0
|
1
|
|
say $_[0]->get_runtime_format; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
__END__ |