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