« blib/lib/Lingua/Ogmios/NLPWrappers/Template.pm
↑ Summary
blib/lib/Lingua/Ogmios/DocumentCollection.pm »
| 1 | package Lingua::Ogmios::Timer; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 16 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 16 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 16 | ▶ | use Time::HiRes qw( gettimeofday tv_interval); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 16 | my $debug_devel_level = 0; | |||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 39 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 11 | 39 | my ($class) = @_; | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 39 | my $timer = { | |||||||||||||||||||||||||||
| 14 | 'timeStart' => undef, | ||||||||||||||||||||||||||||
| 15 | 'temporaryTimeEnd' => undef, | ||||||||||||||||||||||||||||
| 16 | 'userTimeStart' => undef, | ||||||||||||||||||||||||||||
| 17 | 'userTimeEnd' => undef, | ||||||||||||||||||||||||||||
| 18 | 'NumberOfSteps' => 0, | ||||||||||||||||||||||||||||
| 19 | 'laps' => [], | ||||||||||||||||||||||||||||
| 20 | 'userTimeStartBySteps' => [], | ||||||||||||||||||||||||||||
| 21 | 'userTimeEndBySteps' => [], | ||||||||||||||||||||||||||||
| 22 | 'timeByCategory' => {}, | ||||||||||||||||||||||||||||
| 23 | }; | ||||||||||||||||||||||||||||
| 24 | 39 | bless $timer, $class; | |||||||||||||||||||||||||||
| 25 | 39 | return $timer; | |||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | # By Category | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 0 | ▶ | sub getTimeByCategory { | ||||||||||||||||||||||||||
|
Subroutine
getTimeByCategory: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 31 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 0 | return($self->{"timeByCategory"}); | |||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 0 | ▶ | sub resetTimeByCategory { | ||||||||||||||||||||||||||
|
Subroutine
resetTimeByCategory: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 38 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 0 | $self->{"timeByCategory"} = {}; | |||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 0 | ▶ | sub addNewCategory { | ||||||||||||||||||||||||||
|
Subroutine
addNewCategory: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 45 | 0 | my ($self, $categoryName) = @_; | |||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 0 | ▶ | if (!exists $self->getTimeByCategory->{$categoryName}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 48 | 0 | $self->getTimeByCategory->{$categoryName} = {'times' => [], | |||||||||||||||||||||||||||
| 49 | 'lastItem' => -1, | ||||||||||||||||||||||||||||
| 50 | }; | ||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | 0 | return($self->getTimeByCategory->{$categoryName}); | |||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 0 | ▶ | sub getCategory { | ||||||||||||||||||||||||||
|
Subroutine
getCategory: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 56 | 0 | my ($self, $categoryName) = @_; | |||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 0 | return($self->getTimeByCategory->{$categoryName}); | |||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 0 | ▶ | sub startsLapByCategory { | ||||||||||||||||||||||||||
|
Subroutine
startsLapByCategory: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 62 | 0 | my ($self, $categoryName) = @_; | |||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | 0 | my $time = [gettimeofday]; | |||||||||||||||||||||||||||
| 65 | 0 | my $category = $self->getCategory($categoryName); | |||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 0 | ▶ | if (!defined $category) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 68 | 0 | $category = $self->addNewCategory($categoryName); | |||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | # warn $self->getLastItem($category); | ||||||||||||||||||||||||||||
| 72 | 0 | push @{$category->{'times'}}, {'start' => $time, 'end' => $time}; | |||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 0 | $category->{'lastItem'}++; | |||||||||||||||||||||||||||
| 75 | # warn $self->getLastItem($category); | ||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | 0 | ▶ | sub endsLapByCategory { | ||||||||||||||||||||||||||
|
Subroutine
endsLapByCategory: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 79 | 0 | my ($self, $categoryName, $item) = @_; | |||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | 0 | my $category = $self->getCategory($categoryName); | |||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | 0 | ▶ | if (!defined($item)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 84 | # warn "not defined item for $categoryName\n"; | ||||||||||||||||||||||||||||
| 85 | 0 | $item = $self->getLastItem($category); | |||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | 0 | ▶ | if (!defined $item) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 89 | 0 | warn " not defined item for $categoryName\n"; | |||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||
| 91 | 0 | $category->{'times'}->[$item]->{'end'} = [gettimeofday]; | |||||||||||||||||||||||||||
| 92 | # $category->{'lastItem'}--; | ||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | 0 | ▶ | sub getLastItem { | ||||||||||||||||||||||||||
|
Subroutine
getLastItem: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 96 | 0 | my ($self, $category) = @_; | |||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | # warn $category->{'lastItem'} . "\n"; | ||||||||||||||||||||||||||||
| 99 | 0 | return($category->{'lastItem'}); | |||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | 0 | ▶ | sub _printTimeByCategory { | ||||||||||||||||||||||||||
|
Subroutine
_printTimeByCategory: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||
| 103 | 0 | my ($self, $printDetails) = @_; | |||||||||||||||||||||||||||
| 104 | 0 | my $categoryName; | |||||||||||||||||||||||||||
| 105 | my $i; | ||||||||||||||||||||||||||||
| 106 | 0 | my $timeSum; | |||||||||||||||||||||||||||
| 107 | 0 | my $time; | |||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | 0 | foreach $categoryName (keys %{$self->getTimeByCategory}) { | |||||||||||||||||||||||||||
| 110 | 0 | warn "Category: $categoryName\n"; | |||||||||||||||||||||||||||
| 111 | 0 | $timeSum = 0; | |||||||||||||||||||||||||||
| 112 | 0 | ▶ | for($i=0;$i < scalar(@{$self->getCategory($categoryName)->{'times'}});$i++) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 113 | 0 | $time = tv_interval($self->getCategory($categoryName)->{'times'}->[$i]->{'start'}, $self->getCategory($categoryName)->{'times'}->[$i]->{'end'}); | |||||||||||||||||||||||||||
| 114 | 0 | $timeSum += $time; | |||||||||||||||||||||||||||
| 115 | 0 | ▶ | if ((!defined $printDetails) || ($printDetails != 0)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $printDetails or $printDetails != 0
MC/DC0%0/2
not defined $printDetails or $printDetails != 0
not defined $printDetails
$printDetails != 0
Truth table0%0/3
not(A) or B
A= not defined $printDetailsB= $printDetails != 0
| |||||||||||||||||||||||||||||
| 116 | 0 | warn "\tItem $i: $time\n"; | |||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||
| 119 | 0 | warn " Total: $timeSum\n"; | |||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||
| 121 | 0 | warn "\n"; | |||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | ######################################################################## | ||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | # Lap (BySteps) | ||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | 2 | ▶ | sub startsLap { | ||||||||||||||||||||||||||
|
Subroutine
startsLap: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 133 | 2 | my ($self, $stepName) = @_; | |||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||
| 135 | 2 | $self->incrNumberOfSteps; | |||||||||||||||||||||||||||
| 136 | 2 | $self->setLap($stepName); | |||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | 2 | ▶ | sub getLaps { | ||||||||||||||||||||||||||
|
Subroutine
getLaps: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 141 | 2 | my $self = shift; | |||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | 2 | return $self->{'laps'}; | |||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | 2 | ▶ | sub setLap { | ||||||||||||||||||||||||||
|
Subroutine
setLap: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 147 | 2 | my ($self, $stepName) = @_; | |||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | 2 | my $time = [gettimeofday]; | |||||||||||||||||||||||||||
| 150 | 2 | $self->getLaps->[$self->NumberOfSteps - 1] = {'timeStart' => $time, | |||||||||||||||||||||||||||
| 151 | 'stepName' => $stepName}; | ||||||||||||||||||||||||||||
| 152 | 2 | $self->lapStartUserTimeBySteps($time); | |||||||||||||||||||||||||||
| 153 | 2 | $self->lapEndUserTimeBySteps($time); | |||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||
| 156 | 10 | ▶ | sub NumberOfSteps { | ||||||||||||||||||||||||||
|
Subroutine
NumberOfSteps: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 157 | 10 | my $self = shift; | |||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | 10 | ▶ | $self->{'NumberOfSteps'} = shift if @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 160 | 10 | return $self->{'NumberOfSteps'}; | |||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||
| 163 | 0 | ▶ | sub getLapCurrentStep { | ||||||||||||||||||||||||||
|
Subroutine
getLapCurrentStep: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 164 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||
| 166 | 0 | return($self->{'laps'}->[$self->NumberOfSteps - 1]); | |||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||
| 169 | 0 | ▶ | sub getTimeLapCurrentStep { | ||||||||||||||||||||||||||
|
Subroutine
getTimeLapCurrentStep: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 170 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | 0 | return($self->getLapCurrentStep->{'timeStart'}); | |||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||
| 175 | 0 | ▶ | sub getNameLapCurrentStep { | ||||||||||||||||||||||||||
|
Subroutine
getNameLapCurrentStep: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 176 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||
| 178 | 0 | return($self->getLapCurrentStep->{'stepName'}); | |||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||
| 181 | 2 | ▶ | sub incrNumberOfSteps { | ||||||||||||||||||||||||||
|
Subroutine
incrNumberOfSteps: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 182 | 2 | my ($self) = @_; | |||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||
| 184 | 2 | return($self->NumberOfSteps($self->NumberOfSteps + 1)); | |||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||
| 187 | 2 | ▶ | sub lapStartUserTimeBySteps { | ||||||||||||||||||||||||||
|
Subroutine
lapStartUserTimeBySteps: called CC=2 SCAR=7.6
Pod
undocumented
| |||||||||||||||||||||||||||||
| 188 | 2 | my ($self, $value) = @_; | |||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||
| 190 | 2 | ▶ | if (!defined $value) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 191 | 0 | $value = [gettimeofday]; | |||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||
| 193 | 2 | $self->getUserTimeStartBySteps->[$self->NumberOfSteps - 1] = $value; | |||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||
| 196 | 2 | ▶ | sub lapEndUserTimeBySteps { | ||||||||||||||||||||||||||
|
Subroutine
lapEndUserTimeBySteps: called CC=2 SCAR=7.6
Pod
undocumented
| |||||||||||||||||||||||||||||
| 197 | 2 | my ($self, $value) = @_; | |||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||
| 199 | 2 | ▶ | if (!defined $value) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 200 | 0 | $value = [gettimeofday]; | |||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||
| 202 | 2 | $self->getUserTimeEndBySteps->[$self->NumberOfSteps - 1] = $value; | |||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||
| 205 | 2 | ▶ | sub getUserTimeStartBySteps { | ||||||||||||||||||||||||||
|
Subroutine
getUserTimeStartBySteps: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 206 | 2 | my ($self) = @_; | |||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||
| 208 | 2 | return($self->{'userTimeStartBySteps'}); | |||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||
| 211 | 2 | ▶ | sub getUserTimeEndBySteps { | ||||||||||||||||||||||||||
|
Subroutine
getUserTimeEndBySteps: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 212 | 2 | my ($self) = @_; | |||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||
| 214 | 2 | return($self->{'userTimeEndBySteps'}); | |||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||
| 217 | 0 | ▶ | sub getLapUserTimeStartBySteps { | ||||||||||||||||||||||||||
|
Subroutine
getLapUserTimeStartBySteps: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 218 | 0 | my ($self, $step) = @_; | |||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||
| 220 | 0 | ▶ | if (!defined $step) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 221 | 0 | $step = $self->NumberOfSteps - 1; | |||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||
| 224 | 0 | return($self->getUserTimeStartBySteps->[$step]); | |||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||
| 227 | 0 | ▶ | sub getLapUserTimeEndBySteps { | ||||||||||||||||||||||||||
|
Subroutine
getLapUserTimeEndBySteps: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 228 | 0 | my ($self, $step) = @_; | |||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||
| 230 | 0 | ▶ | if (!defined $step) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 231 | 0 | $step = $self->NumberOfSteps - 1; | |||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||
| 234 | 0 | return($self->getUserTimeEndBySteps->[$step]); | |||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||
| 237 | 0 | ▶ | sub getTimesBySteps { | ||||||||||||||||||||||||||
|
Subroutine
getTimesBySteps: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 238 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||
| 240 | 0 | my $userTime = 0; | |||||||||||||||||||||||||||
| 241 | 0 | my $systemTimeBefore = 0; | |||||||||||||||||||||||||||
| 242 | 0 | my $systemTimeAfter = 0; | |||||||||||||||||||||||||||
| 243 | 0 | my $systemTime = 0; | |||||||||||||||||||||||||||
| 244 | 0 | my $fullTime = 0; | |||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||
| 246 | 0 | my $currentTime = [gettimeofday]; | |||||||||||||||||||||||||||
| 247 | 0 | $userTime = tv_interval($self->getLapUserTimeStartBySteps, $self->getLapUserTimeEndBySteps) ; | |||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||
| 249 | 0 | $systemTimeBefore = tv_interval($self->getTimeLapCurrentStep, $self->getLapUserTimeStartBySteps) ; | |||||||||||||||||||||||||||
| 250 | 0 | $systemTimeAfter = tv_interval($self->getLapUserTimeEndBySteps, $currentTime); | |||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||
| 252 | 0 | $systemTime = $systemTimeBefore + $systemTimeAfter; | |||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||
| 254 | 0 | $fullTime = tv_interval($self->getTimeLapCurrentStep, $currentTime); | |||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||
| 256 | 0 | return($fullTime, $systemTime, $systemTimeBefore, $systemTimeAfter, $userTime); | |||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||
| 259 | 0 | ▶ | sub _printTimesBySteps { | ||||||||||||||||||||||||||
|
Subroutine
_printTimesBySteps: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 260 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||
| 262 | 0 | my @times = $self->getTimesBySteps; | |||||||||||||||||||||||||||
| 263 | 0 | warn " Step: " . ($self->NumberOfSteps - 1) . " (step: " . $self->getNameLapCurrentStep . ")\n"; | |||||||||||||||||||||||||||
| 264 | 0 | warn "\tFull time processing: " . $times[0] . "\n"; | |||||||||||||||||||||||||||
| 265 | 0 | warn "\tSystem time processing: " . $times[1] . "\n"; | |||||||||||||||||||||||||||
| 266 | 0 | warn "\tSystem time processing (Before): " . $times[2] . "\n"; | |||||||||||||||||||||||||||
| 267 | 0 | warn "\tSystem time processing (After): " . $times[3] . "\n"; | |||||||||||||||||||||||||||
| 268 | 0 | warn "\tUser time processing: " . $times[4] . "\n"; | |||||||||||||||||||||||||||
| 269 | 0 | warn "\n"; | |||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||
| 272 | ######################################################################## | ||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||
| 274 | 39 | ▶ | sub start { | ||||||||||||||||||||||||||
|
Subroutine
start: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 275 | 39 | my ($self) = @_; | |||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||
| 277 | 39 | $self->{'timeStart'} = [gettimeofday]; | |||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||
| 280 | 14 | ▶ | sub suspendWithUserTime { | ||||||||||||||||||||||||||
|
Subroutine
suspendWithUserTime: called CC=6 SCAR=18.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 281 | 14 | my ($self) = @_; | |||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||
| 283 | 14 | my $userTimeInterval = 0; | |||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||
| 285 | 14 | my $lastTemporaryTimeEnd = $self->getTemporaryTimeEnd; | |||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||
| 287 | 14 | ▶ | if (!defined $lastTemporaryTimeEnd ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 288 | 13 | $lastTemporaryTimeEnd = $self->getTimeStart; | |||||||||||||||||||||||||||
| 289 | 13 | ▶ | if (!defined $lastTemporaryTimeEnd ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 290 | 0 | warn "The timer is not start. Timer functions disabled\n"; | |||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||
| 293 | 14 | $self->{'temporaryTimeEnd'} = [gettimeofday]; | |||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||
| 295 | 14 | my $fullTimeInterval = tv_interval ( $lastTemporaryTimeEnd, $self->{'temporaryTimeEnd'} ) ; | |||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||
| 297 | 14 | my $startUserTime = $self->getStartUserTime; | |||||||||||||||||||||||||||
| 298 | 14 | my $endUserTime = $self->getEndUserTime; | |||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||
| 300 | 14 | ▶ | if (!defined($startUserTime) && !(defined $endUserTime)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $startUserTime || defined $endUserTime
MC/DC50%1/2
defined $startUserTime || defined $endUserTime
defined $startUserTime
defined $endUserTime
Truth table66%2/3
A || B
A= defined $startUserTimeB= defined $endUserTime
| |||||||||||||||||||||||||||||
| 301 | 13 | warn "The user time not set. Feature disabled\n"; | |||||||||||||||||||||||||||
| 302 | } else { | ||||||||||||||||||||||||||||
| 303 | 1 | $userTimeInterval = tv_interval($self->getStartUserTime, $self->getEndUserTime); | |||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||
| 306 | 14 | my $systemTimeInterval = 0; | |||||||||||||||||||||||||||
| 307 | 14 | ▶ | if (defined $userTimeInterval) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 308 | 14 | $systemTimeInterval = $fullTimeInterval - $userTimeInterval; | |||||||||||||||||||||||||||
| 309 | } else { | ||||||||||||||||||||||||||||
| 310 | 0 | $systemTimeInterval = $fullTimeInterval; | |||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||
| 312 | 14 | return($fullTimeInterval, $systemTimeInterval, $userTimeInterval); | |||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||
| 315 | 0 | ▶ | sub _printTimes { | ||||||||||||||||||||||||||
|
Subroutine
_printTimes: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 316 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||
| 318 | 0 | my @times = $self->suspendWithUserTime; | |||||||||||||||||||||||||||
| 319 | 0 | warn "\tFull time processing: " . $times[0] . "\n"; | |||||||||||||||||||||||||||
| 320 | 0 | warn "\tSystem time processing: " . $times[1] . "\n"; | |||||||||||||||||||||||||||
| 321 | 0 | warn "\tUser time processing: " . $times[2] . "\n"; | |||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||
| 325 | 13 | ▶ | sub _printTimesInLine { | ||||||||||||||||||||||||||
|
Subroutine
_printTimesInLine: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 326 | 13 | my ($self,$tool) = @_; | |||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||
| 328 | 13 | my @times = $self->suspendWithUserTime; | |||||||||||||||||||||||||||
| 329 | 13 | warn "# tool\tFull time processing\tSystem time processing\tUser time processing\n"; | |||||||||||||||||||||||||||
| 330 | 13 | warn "Running Time for $tool\t" . $times[0] . "\t" . $times[1] . "\t" . $times[2] . "\n"; | |||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||
| 333 | 1 | ▶ | sub markEndUserTime { | ||||||||||||||||||||||||||
|
Subroutine
markEndUserTime: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 334 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||
| 336 | 1 | $self->{'userTimeEnd'} = [gettimeofday]; | |||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||
| 339 | 1 | ▶ | sub markStartUserTime { | ||||||||||||||||||||||||||
|
Subroutine
markStartUserTime: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 340 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||
| 342 | 1 | $self->{'userTimeStart'} = [gettimeofday]; | |||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||
| 345 | 16 | ▶ | sub getEndUserTime { | ||||||||||||||||||||||||||
|
Subroutine
getEndUserTime: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 346 | 16 | my ($self) = @_; | |||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||
| 348 | 16 | return($self->{'userTimeEnd'}); | |||||||||||||||||||||||||||
| 349 | } | ||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||
| 351 | 16 | ▶ | sub getStartUserTime { | ||||||||||||||||||||||||||
|
Subroutine
getStartUserTime: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 352 | 16 | my ($self) = @_; | |||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||
| 354 | 16 | return($self->{'userTimeStart'}); | |||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||
| 357 | 1 | ▶ | sub suspend { | ||||||||||||||||||||||||||
|
Subroutine
suspend: called CC=3 SCAR=11.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 358 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||
| 360 | 1 | my $lastTemporaryTimeEnd = $self->getTemporaryTimeEnd; | |||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||
| 362 | 1 | ▶ | if (!defined $lastTemporaryTimeEnd ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 363 | 1 | $lastTemporaryTimeEnd = $self->getTimeStart; | |||||||||||||||||||||||||||
| 364 | 1 | ▶ | if (!defined $lastTemporaryTimeEnd ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 365 | 0 | warn "The timer is not start. Timer functions disabled\n"; | |||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||
| 368 | 1 | $self->{'temporaryTimeEnd'} = [gettimeofday]; | |||||||||||||||||||||||||||
| 369 | 1 | return(tv_interval ( $lastTemporaryTimeEnd, $self->{'temporaryTimeEnd'} ) ); | |||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||
| 372 | 1 | ▶ | sub suspendFromStart { | ||||||||||||||||||||||||||
|
Subroutine
suspendFromStart: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 373 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||
| 375 | 1 | $self->{'temporaryTimeEnd'} = [gettimeofday]; | |||||||||||||||||||||||||||
| 376 | 1 | return(tv_interval ( $self->getTimeStart, $self->{'temporaryTimeEnd'} ) ); | |||||||||||||||||||||||||||
| 377 | } | ||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||
| 379 | 0 | ▶ | sub reset { | ||||||||||||||||||||||||||
|
Subroutine
reset: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 380 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||
| 382 | 0 | $self->{'startTime'} = undef; | |||||||||||||||||||||||||||
| 383 | 0 | $self->{'temporaryTimeEnd'} = undef; | |||||||||||||||||||||||||||
| 384 | } | ||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||
| 386 | 15 | ▶ | sub getTemporaryTimeEnd { | ||||||||||||||||||||||||||
|
Subroutine
getTemporaryTimeEnd: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 387 | 15 | my ($self) = @_; | |||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||
| 389 | 15 | return($self->{'temporaryTimeEnd'}); | |||||||||||||||||||||||||||
| 390 | } | ||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||
| 392 | 0 | ▶ | sub setTemporaryTimeEnd { | ||||||||||||||||||||||||||
|
Subroutine
setTemporaryTimeEnd: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 393 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||
| 395 | 0 | $self->{'temporaryTimeEnd'} = [gettimeofday]; | |||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||
| 398 | 16 | ▶ | sub getTimeStart { | ||||||||||||||||||||||||||
|
Subroutine
getTimeStart: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 399 | 16 | my ($self) = @_; | |||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||
| 401 | 16 | return($self->{'timeStart'}); | |||||||||||||||||||||||||||
| 402 | } | ||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||
| 404 | 1 | ▶ | sub getTime { | ||||||||||||||||||||||||||
|
Subroutine
getTime: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 405 | 1 | my ($self, $time) = @_; | |||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||
| 407 | 1 | my $sec = $time->[0]; | |||||||||||||||||||||||||||
| 408 | 1 | my $usec = $time->[1]; | |||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||
| 410 | 1 | return($sec+$usec*1e6); | |||||||||||||||||||||||||||
| 411 | } | ||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||
| 413 | 16 | 1; | |||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||
| 415 | __END__ | ||||||||||||||||||||||||||||