blib/lib/Time/HiRes.pm untested

filter: Statementstmt 0.0% 0 / 54 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 45 MC/DCmcdc 0.0% 0 / 24 Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 143 CC 5 SCAR 17.1
CC
5
Cov
0%
AUTOLOAD
12.0
import
6.0
tv_interval
6.0
CRAP 5.5
1 package Time::HiRes;
2  
3 { use 5.006; }
4 use strict;
5  
6 require Exporter;
7 use XSLoader ();
8  
9 our @ISA = qw(Exporter);
10  
11 our @EXPORT = qw( );
12 # More or less this same list is in Makefile.PL. Should unify.
13 our @EXPORT_OK = qw (usleep sleep ualarm alarm gettimeofday time tv_interval
14 getitimer setitimer nanosleep clock_gettime clock_getres
15 clock clock_nanosleep
16 CLOCKS_PER_SEC
17 CLOCK_BOOTTIME
18 CLOCK_HIGHRES
19 CLOCK_MONOTONIC
20 CLOCK_MONOTONIC_COARSE
21 CLOCK_MONOTONIC_FAST
22 CLOCK_MONOTONIC_PRECISE
23 CLOCK_MONOTONIC_RAW
24 CLOCK_PROCESS_CPUTIME_ID
25 CLOCK_PROF
26 CLOCK_REALTIME
27 CLOCK_REALTIME_COARSE
28 CLOCK_REALTIME_FAST
29 CLOCK_REALTIME_PRECISE
30 CLOCK_REALTIME_RAW
31 CLOCK_SECOND
32 CLOCK_SOFTTIME
33 CLOCK_THREAD_CPUTIME_ID
34 CLOCK_TIMEOFDAY
35 CLOCK_UPTIME
36 CLOCK_UPTIME_COARSE
37 CLOCK_UPTIME_FAST
38 CLOCK_UPTIME_PRECISE
39 CLOCK_UPTIME_RAW
40 CLOCK_VIRTUAL
41 ITIMER_PROF
42 ITIMER_REAL
43 ITIMER_REALPROF
44 ITIMER_VIRTUAL
45 TIMER_ABSTIME
46 d_usleep d_ualarm d_gettimeofday d_getitimer d_setitimer
47 d_nanosleep d_clock_gettime d_clock_getres
48 d_clock d_clock_nanosleep d_hires_stat
49 d_futimens d_utimensat d_hires_utime
50 stat lstat utime
51 );
52  
53 our $VERSION = '1.9764_02';
54 our $XS_VERSION = $VERSION;
55 $VERSION = eval $VERSION;
56  
57 our $AUTOLOAD;
58 sub AUTOLOAD {
59 my $constname;
60 ($constname = $AUTOLOAD) =~ s/.*:://;
61 # print "AUTOLOAD: constname = $constname ($AUTOLOAD)\n";
62 die "&Time::HiRes::constant not defined" if $constname eq 'constant';
63 my ($error, $val) = constant($constname);
64 # print "AUTOLOAD: error = $error, val = $val\n";
65 if ($error) {
66 my (undef,$file,$line) = caller;
67 die "$error at $file line $line.\n";
68 }
69 {
70 no strict 'refs';
71 *$AUTOLOAD = sub { $val };
72 }
73 goto &$AUTOLOAD;
74 }
75  
76 sub import {
77 my $this = shift;
78 for my $i (@_) {
79 if (($i eq 'clock_getres' && !&d_clock_getres) ||
80 ($i eq 'clock_gettime' && !&d_clock_gettime) ||
81 ($i eq 'clock_nanosleep' && !&d_clock_nanosleep) ||
82 ($i eq 'clock' && !&d_clock) ||
83 ($i eq 'nanosleep' && !&d_nanosleep) ||
84 ($i eq 'usleep' && !&d_usleep) ||
85 ($i eq 'utime' && !&d_hires_utime) ||
86 ($i eq 'ualarm' && !&d_ualarm)) {
87 require Carp;
88 Carp::croak("Time::HiRes::$i(): unimplemented in this platform");
89 }
90 }
91 Time::HiRes->export_to_level(1, $this, @_);
92 }
93  
94 XSLoader::load( 'Time::HiRes', $XS_VERSION );
95  
96 # Preloaded methods go here.
97  
98 sub tv_interval {
99 # probably could have been done in C
100 my ($a, $b) = @_;
101 $b = [gettimeofday()] unless defined($b);
102 (${$b}[0] - ${$a}[0]) + ((${$b}[1] - ${$a}[1]) / 1_000_000);
103 }
104  
105 # Autoload methods go after =cut, and are processed by the autosplit program.
106  
107 1;
108 __END__