DataDog/Utils.pm

filter: Statementstmt 72.7% 8 / 11 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 40.0% 2 / 5 Podpod 100% 3 / 3 totaltotal 68.4% 13 / 19 CC 1 SCAR 4.7
CC
1
Cov
73%
random_64bit_int
2.0
nano_seconds
2.0
epoch_floatingpoint
2.0
CRAP 1.6
« DataDog/Agent.pm ↑ Summary DataDog.pm »
1 package OpenTracing::Implementation::DataDog::Utils;
2  
3 =head1 NAME
4  
5 OpenTracing::Implementation::DataDog::Utils - DataDog Utilities
6  
7 =cut
8  
9 6 ▶use Exporter qw/import/;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 6 our @EXPORT_OK = qw/random_64bit_int nano_seconds epoch_floatingpoint/;
12  
13 6 ▶use Time::HiRes qw( gettimeofday );
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 =head1 EXPORTS OK
16  
17 The following subroutines can be imported into your namespance:
18  
19 =cut
20  
21  
22  
23 =head2 random_64bit_int
24  
25 Generates a 64bit integers (or actually a 63bit, or signed 64bit)
26  
27 =cut
28  
29 0 ▶sub random_64bit_int { int(rand( 2**63 )) }
Subroutine random_64bit_int: not called CC=1 SCAR=6.9
Pod documented
30  
31  
32  
33 =head2 nano_seconds
34  
35 To turn floatingpoint times into number of nano seconds
36  
37 =cut
38  
39 0 ▶sub nano_seconds { int( $_[0] * 1_000_000_000 ) }
Subroutine nano_seconds: not called CC=1 SCAR=6.9
Pod documented
40  
41  
42  
43 =head2 epoch_floatingpoint
44  
45 Well, returns the time since 'epoch' with fractional seconds, as floating-point.
46  
47 =cut
48  
49 sub epoch_floatingpoint {
50 0 ▶ return scalar gettimeofday()
Subroutine epoch_floatingpoint: not called CC=1 SCAR=6.9
Pod documented
51 }
52 #
53 # well, this is a bit off a silly idea:
54 # some implentations may want nano-second accuracy, but floating point
55 # computations using 64bits (IEEE) are only having 16 digits in the mantissa.
56 # The number of nano-seconds since epoch is 19 digits that barely fits in a
57 # signed 64 bit integer.
58  
59  
60 6 1;
« DataDog/Agent.pm ↑ Summary DataDog.pm »