line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyright © 2015 David Caldwell . |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# This library is free software; you can redistribute it and/or modify |
4
|
|
|
|
|
|
|
# it under the same terms as Perl itself, either Perl version 5.12.4 or, |
5
|
|
|
|
|
|
|
# at your option, any later version of Perl 5 you may have available. |
6
|
|
|
|
|
|
|
|
7
|
4
|
|
|
4
|
|
93378
|
use strict; use warnings; |
|
4
|
|
|
4
|
|
9
|
|
|
4
|
|
|
|
|
162
|
|
|
4
|
|
|
|
|
21
|
|
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
251
|
|
8
|
|
|
|
|
|
|
package Time::Monotonic; |
9
|
4
|
|
|
4
|
|
20
|
use Exporter 'import'; |
|
4
|
|
|
|
|
13
|
|
|
4
|
|
|
|
|
1381
|
|
10
|
|
|
|
|
|
|
our @EXPORT_OK = qw(monotonic_time); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = 'v0.9.7'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
require XSLoader; |
15
|
|
|
|
|
|
|
XSLoader::load('Time::Monotonic', $VERSION); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub monotonic_time { |
18
|
8
|
|
|
8
|
1
|
1459
|
Time::Monotonic::clock_get_dbl(); |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub backend { |
22
|
1
|
|
|
1
|
1
|
16
|
Time::Monotonic::monotonic_clock_name(); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub is_monotonic { |
26
|
1
|
|
|
1
|
1
|
8
|
Time::Monotonic::monotonic_clock_is_monotonic(); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub new { |
30
|
2
|
|
|
2
|
0
|
400
|
my ($class, $offset) = @_; |
31
|
2
|
|
100
|
|
|
5
|
my $now = monotonic_time() + ($offset // 0); |
32
|
2
|
|
33
|
|
|
11
|
bless \$now => ref $class || $class; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub now { |
36
|
4
|
|
|
4
|
0
|
1395
|
my $self = shift; |
37
|
4
|
|
|
|
|
6
|
return monotonic_time() - $$self; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
1; |
41
|
|
|
|
|
|
|
__END__ |