| 1 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | =encoding utf8 | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | =head1 NAME | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | Quiq::Progress - Berechne Fortschrittsinformation | ||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | =head1 BASE CLASS | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | L<Quiq::Hash> | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | Mit print: | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | use Quiq::Progress; | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | $| = 1; | ||||||||||||||||||||||||||||
| 20 | my $n = 5; | ||||||||||||||||||||||||||||
| 21 | my $p = Quiq::Progress->new($n); | ||||||||||||||||||||||||||||
| 22 | print $p->msg('Waiting...'); | ||||||||||||||||||||||||||||
| 23 | for my $i (1 .. $n) { | ||||||||||||||||||||||||||||
| 24 | sleep 1; | ||||||||||||||||||||||||||||
| 25 | print $p->msg($i,'i/n x% t/t(t) x/s t/1'); | ||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||
| 27 | print $p->msg; | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | Mit R1::Log2: | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | use R1::Log2; | ||||||||||||||||||||||||||||
| 32 | use Quiq::Progress; | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | my $log = R1::Log2->new(\*STDOUT); | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | my $msg; | ||||||||||||||||||||||||||||
| 37 | my $n = 5; | ||||||||||||||||||||||||||||
| 38 | my $p = Quiq::Progress->new($n); | ||||||||||||||||||||||||||||
| 39 | for my $i (1 .. $n) { | ||||||||||||||||||||||||||||
| 40 | sleep 1; | ||||||||||||||||||||||||||||
| 41 | $msg = sprintf '%s %s %s %s %s',$p->info($i); | ||||||||||||||||||||||||||||
| 42 | $log->printCr($msg); | ||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||
| 44 | $log->printLn($msg); | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | Ohne Gesamtanzahl der Schritte. Anmerkungen: | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | =over 2 | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | =item * | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | die Ausgabe der Prozentangabe wird unterdrückt | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | =item * | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | alle Ausgaben erfolgen ohne Bezug zu einer Gesamtanzahl (statt | ||||||||||||||||||||||||||||
| 57 | Ausgabe I/N nur I, statt ZEIT/GESAMTZEIT(RESTZEIT) nur ZEIT) | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | use Quiq::Progress; | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | $| = 1; | ||||||||||||||||||||||||||||
| 62 | my $p = Quiq::Progress->new; | ||||||||||||||||||||||||||||
| 63 | for my $i (1 .. 5) { | ||||||||||||||||||||||||||||
| 64 | print $p->msg($i,'i/n x% t/t(t) x/h x/s t/1'); | ||||||||||||||||||||||||||||
| 65 | sleep 1; | ||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | print $p->msg; | ||||||||||||||||||||||||||||
| 68 | 1 0s 3600000/h 1000.00/s 0.00s/1\r | ||||||||||||||||||||||||||||
| 69 | 2 1s 7200/h 2.00/s 0.50s/1\r | ||||||||||||||||||||||||||||
| 70 | 3 2s 5400/h 1.50/s 0.67s/1\r | ||||||||||||||||||||||||||||
| 71 | 4 3s 4788/h 1.33/s 0.75s/1\r | ||||||||||||||||||||||||||||
| 72 | 5 4s 4500/h 1.25/s 0.80s/1\r | ||||||||||||||||||||||||||||
| 73 | 5 5s 3600/h 1.00/s 1.00s/1\r | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | =back | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | =head1 ATTRIBUTES | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | =over 4 | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | =item n | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | Gesamtzahl der Schritte | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | =item t0 | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | Startzeitpunkt | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | =item i | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | Aktueller Schritt | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | =item duration | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | Vergangene Zeit in Sekunden (mit Nachkommastellen) | ||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | =item msg | ||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | Die letzte von msg() erzeugte Meldung. | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | =back | ||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | =cut | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | package Quiq::Progress; | ||||||||||||||||||||||||||||
| 108 | 16 | ▶ | use base qw/Quiq::Hash/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | 16 | ▶ | use v5.10; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 111 | 16 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 112 | 16 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | 16 | our $VERSION = '1.240'; | |||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | 16 | ▶ | use Quiq::Option; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 117 | 16 | ▶ | use Time::HiRes (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 118 | 16 | ▶ | use Quiq::Duration; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 119 | 16 | ▶ | use Quiq::Math; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | =head1 METHODS | ||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | =head2 Konstruktor | ||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | =head3 new() - Konstruktor | ||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | =head4 Synopsis | ||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | $pi = $class->new($n,@opt); | ||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | =head4 Arguments | ||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||
| 135 | =over 4 | ||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||
| 137 | =item $n | ||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | Gesamtzahl der Schritte | ||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | =back | ||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | =head4 Options | ||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | =over 4 | ||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | =item -show => $bool (Default: 1) | ||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | Die Klasse liefert Meldungen. Mit -show=>0 kann die Ausgabe von | ||||||||||||||||||||||||||||
| 150 | Meldungen an-/abgeschaltet werden. Beispiel: | ||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | $pi = $class->new($n,-show=>$verbose); | ||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | =back | ||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||
| 156 | =head4 Returns | ||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | Referenz auf Progress-Objekt | ||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||
| 160 | =cut | ||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||
| 162 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | 11 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||
| 165 | 11 | my $class = shift; | |||||||||||||||||||||||||||
| 166 | # @_: $n,@opt -or- @opt | ||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | # Optionen und Argumente | ||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||
| 170 | 11 | my $show = 1; | |||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | 11 | Quiq::Option->extract(\@_, | |||||||||||||||||||||||||||
| 173 | -show => \$show, | ||||||||||||||||||||||||||||
| 174 | ); | ||||||||||||||||||||||||||||
| 175 | 11 | ▶ | my $n = shift || 0; | ||||||||||||||||||||||||||
|
Condition50%1/2
shift() || 0
MC/DC0%0/1
shift() || 0
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||
| 177 | # Objekt instantiieren | ||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||
| 179 | 11 | my $self = $class->SUPER::new( | |||||||||||||||||||||||||||
| 180 | t0 => scalar Time::HiRes::gettimeofday, | ||||||||||||||||||||||||||||
| 181 | n => $n, | ||||||||||||||||||||||||||||
| 182 | duration => 0, | ||||||||||||||||||||||||||||
| 183 | i => 0, | ||||||||||||||||||||||||||||
| 184 | fmt => '', # letztes Format | ||||||||||||||||||||||||||||
| 185 | msg => '', # letzte Meldung | ||||||||||||||||||||||||||||
| 186 | show => $show, | ||||||||||||||||||||||||||||
| 187 | ); | ||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||
| 189 | 11 | return $self; | |||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||
| 192 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||
| 194 | =head2 Schritt setzen | ||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||
| 196 | =head3 step() - Setze Progress-Objekt auf nächsten Schritt | ||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||
| 198 | =head4 Synopsis | ||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||
| 200 | $pi->step($i); | ||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||
| 202 | =head4 Arguments | ||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||
| 204 | =over 4 | ||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||
| 206 | =item $i | ||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||
| 208 | Aktueller Schritt. | ||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||
| 210 | =back | ||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||
| 212 | =cut | ||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||
| 214 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||
| 216 | 11 | ▶ | sub step { | ||||||||||||||||||||||||||
|
Subroutine
step: called CC=3 SCAR=12.0
Pod
documented
| |||||||||||||||||||||||||||||
| 217 | 11 | my ($self,$i) = @_; | |||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||
| 219 | # Wir rechnen mit einer Auflösung von einer tausendstel Sekunde | ||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||
| 221 | 11 | my $d = Time::HiRes::gettimeofday-$self->{'t0'}; | |||||||||||||||||||||||||||
| 222 | 11 | ▶ | if ($d > 0 && $d < 0.001) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$d > 0 and $d < "0.001"
MC/DC0%0/2
$d > 0 and $d < "0.001"
$d > 0
$d < "0.001"
Truth table33%1/3
A and B
A= $d > 0B= $d < "0.001"
| |||||||||||||||||||||||||||||
| 223 | 0 | $d = 0.001; | |||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||
| 226 | 11 | $self->{'i'} = $i; | |||||||||||||||||||||||||||
| 227 | 11 | $self->{'duration'} = $d; | |||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||
| 229 | 11 | return; | |||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||
| 232 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||
| 234 | =head2 Fortschritts- und Performance-Information | ||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||
| 236 | =head3 count() - Liefere "I/N" | ||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||
| 238 | =head4 Synopsis | ||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||
| 240 | $str = $pi->count; | ||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||
| 242 | =head4 Description | ||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||
| 244 | Liefere Stand in der Form "I/N". I ist die Anzahl der absolvierten | ||||||||||||||||||||||||||||
| 245 | Schritte, N ist die Anzahl der Gesamtschritte. | ||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||
| 247 | Liefere Stand in der Form "I", wenn die Anzahl der Gesamtschritte | ||||||||||||||||||||||||||||
| 248 | (N) nicht bekannt ist. | ||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||
| 250 | =cut | ||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||
| 252 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||
| 254 | 11 | ▶ | sub count { | ||||||||||||||||||||||||||
|
Subroutine
count: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||
| 255 | 11 | my $self = shift; | |||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||
| 257 | 11 | my $n = $self->{'n'}; | |||||||||||||||||||||||||||
| 258 | 11 | my $i = $self->{'i'}; | |||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||
| 260 | 11 | ▶ | return $n? "$i/$n": $i; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||
| 263 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||
| 265 | =head3 percent() - Liefere Verarbeitungsstand als Prozentsatz | ||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||
| 267 | =head4 Synopsis | ||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||
| 269 | $str = $pi->percent; | ||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||
| 271 | =head4 Description | ||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||
| 273 | Liefere Verarbeitungsstand in Prozent in der Form "X". Ist die | ||||||||||||||||||||||||||||
| 274 | Gesamtanzahl der Schritte nicht bekannt, liefere einen Leersting. | ||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||
| 276 | =cut | ||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||
| 278 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||
| 280 | 33 | ▶ | sub percent { | ||||||||||||||||||||||||||
|
Subroutine
percent: called CC=2 SCAR=7.4
Pod
documented
| |||||||||||||||||||||||||||||
| 281 | 33 | my $self = shift; | |||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||
| 283 | 33 | my $n = $self->{'n'}; | |||||||||||||||||||||||||||
| 284 | 33 | ▶ | if ($n == 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 285 | 0 | return ''; | |||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||
| 288 | 33 | return sprintf '%.1f',$self->{'i'}/$n*100; | |||||||||||||||||||||||||||
| 289 | # return int($self->{'i'}/$n*100); # immer abrunden | ||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||
| 292 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||
| 294 | =head3 time() - Liefere "HhMmSs/HhMmSs(HhMmSs)" | ||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||
| 296 | =head4 Synopsis | ||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||
| 298 | $str = $pi->time; | ||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||
| 300 | =head4 Description | ||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||
| 302 | Liefere Zeitinformation in der Form "HhMmSs/HhMmSs(HhMmSs)". Der erste | ||||||||||||||||||||||||||||
| 303 | Teil ist die bislang verstrichene Zeit, der zweite Teil die geschätzte | ||||||||||||||||||||||||||||
| 304 | Gesamtzeit, der dritte Teil ist die geschätzte verbleibende Zeit. | ||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||
| 306 | Liefere die Zeitinformation in der Form "HhMmSs", wenn die Anzahl | ||||||||||||||||||||||||||||
| 307 | der Gesamtschritte (N) nicht bekannt ist. | ||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||
| 309 | =cut | ||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||
| 311 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||
| 313 | 11 | ▶ | sub time { | ||||||||||||||||||||||||||
|
Subroutine
time: called CC=4 SCAR=14.8
Pod
documented
| |||||||||||||||||||||||||||||
| 314 | 11 | my $self = shift; | |||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||
| 316 | 11 | my $n = $self->{'n'}; | |||||||||||||||||||||||||||
| 317 | 11 | my $i = $self->{'i'}; | |||||||||||||||||||||||||||
| 318 | 11 | my $duration = $self->{'duration'}; | |||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||
| 320 | 11 | my $durStr .= sprintf '%s',Quiq::Duration->secondsToString($duration); | |||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||
| 322 | 11 | ▶ | if ($duration > 60) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 323 | 0 | $durStr .= sprintf '[%ds]',Quiq::Math->roundToInt($duration); | |||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||
| 325 | 11 | ▶ | if (!$n || !$i) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$n and $i
MC/DC0%0/2
$n and $i
$n
$i
Truth table33%1/3
A and B
A= $nB= $i
| |||||||||||||||||||||||||||||
| 326 | 0 | return $durStr; | |||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||
| 329 | 11 | my $durEst = $duration/$i*$n; | |||||||||||||||||||||||||||
| 330 | 11 | my $durEstStr = Quiq::Duration->secondsToString($durEst); | |||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||
| 332 | 11 | my $delta = $durEst-$duration; | |||||||||||||||||||||||||||
| 333 | 11 | my $deltaStr = Quiq::Duration->secondsToString($delta); | |||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||
| 335 | 11 | return "$durStr/$durEstStr($deltaStr)"; | |||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||
| 338 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||
| 340 | =head3 performance() - Liefere Durchsatz | ||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||
| 342 | =head4 Synopsis | ||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||
| 344 | $str = $pi->performance; | ||||||||||||||||||||||||||||
| 345 | $str = $pi->performance($prec); | ||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||
| 347 | =head4 Arguments | ||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||
| 349 | =over 4 | ||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||
| 351 | =item $prec | ||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||
| 353 | Anzahl Nachkommastellen | ||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||
| 355 | =back | ||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||
| 357 | =head4 Description | ||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||
| 359 | Liefere Durchsatz in der Form "X.XX" (Schritte pro Sekunde). | ||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||
| 361 | =cut | ||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||
| 363 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||
| 365 | 22 | ▶ | sub performance { | ||||||||||||||||||||||||||
|
Subroutine
performance: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||
| 366 | 22 | my ($self,$prec) = @_; | |||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||
| 368 | 22 | ▶ | if (!defined $prec) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 369 | 22 | $prec = 2; | |||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||
| 371 | 22 | return sprintf '%.*f',$prec,$self->{'i'}/$self->{'duration'}; | |||||||||||||||||||||||||||
| 372 | } | ||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||
| 374 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||
| 376 | =head3 timePerStep() - Liefere Zeit pro Schritt | ||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||
| 378 | =head4 Synopsis | ||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||
| 380 | $str = $pi->timePerStep; | ||||||||||||||||||||||||||||
| 381 | $str = $pi->timePerStep($prec); | ||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||
| 383 | =head4 Arguments | ||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||
| 385 | =over 4 | ||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||
| 387 | =item $prec | ||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||
| 389 | Anzahl Nachkommastellen der Sekunde | ||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||
| 391 | =back | ||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||
| 393 | =head4 Description | ||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||
| 395 | Liefere Durchsatz in der Form "HhMmSs.x" (Zeit pro Schritt). | ||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||
| 397 | =cut | ||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||
| 399 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||
| 401 | 0 | ▶ | sub timePerStep { | ||||||||||||||||||||||||||
|
Subroutine
timePerStep: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 402 | 0 | my ($self,$prec) = @_; | |||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||
| 404 | 0 | ▶ | if (!defined $prec) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 405 | 0 | $prec = 2; | |||||||||||||||||||||||||||
| 406 | } | ||||||||||||||||||||||||||||
| 407 | 0 | my $x = $self->{'duration'}/$self->{'i'}; | |||||||||||||||||||||||||||
| 408 | 0 | return Quiq::Duration->secondsToString($x,$prec); | |||||||||||||||||||||||||||
| 409 | } | ||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||
| 411 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||
| 413 | =head2 Information mit einem Aufruf | ||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||
| 415 | =head3 info() - Liefere alle Fortschritts- und Performance-Information | ||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||
| 417 | =head4 Synopsis | ||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||
| 419 | ($count,$percent,$time,$performance,$timePerStep) = $pi->info; | ||||||||||||||||||||||||||||
| 420 | ($count,$percent,$time,$performance,$timePerStep) = $pi->info($i); | ||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||
| 422 | =head4 Arguments | ||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||
| 424 | =over 4 | ||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||
| 426 | =item $i | ||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||
| 428 | Setze auf Schritt $i. Ist $i nicht angegeben, wird kein neuer Schritt | ||||||||||||||||||||||||||||
| 429 | gesetzt, sondern die Information zum aktuellen Schritt geliefert. | ||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||
| 431 | =back | ||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||
| 433 | =head4 Returns | ||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||
| 435 | =over 4 | ||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||
| 437 | =item $count | ||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||
| 439 | Verarbeitungsstand in der Form "I/N". I ist die Anzahl der absolvierten | ||||||||||||||||||||||||||||
| 440 | Schritte, N ist die Anzahl der Gesamtschritte. | ||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||
| 442 | =item $percent | ||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||
| 444 | Verarbeitungsstand in Prozent. | ||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||
| 446 | =item $time | ||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||
| 448 | Zeitinformation in der Form "HhMmSs/HhMmSs". Der erste Teil ist die | ||||||||||||||||||||||||||||
| 449 | bislang verstrichene Zeit, der zweite Teil die geschätzte Gesamtzeit. | ||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||
| 451 | =item $performance | ||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||
| 453 | Durchsatz in der Form "X.XX" (Schritte pro Sekunde). | ||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||
| 455 | =item $timePerStep | ||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||
| 457 | Durchsatz in der Form "HhMmSs.x" (Zeit pro Schritt). | ||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||
| 459 | =back | ||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||
| 461 | =cut | ||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||
| 463 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||
| 465 | 0 | ▶ | sub info { | ||||||||||||||||||||||||||
|
Subroutine
info: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 466 | 0 | my ($self,$i) = @_; | |||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||
| 468 | 0 | ▶ | if ($i) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 469 | 0 | $self->step($i); | |||||||||||||||||||||||||||
| 470 | } | ||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||
| 472 | return ( | ||||||||||||||||||||||||||||
| 473 | 0 | $self->count, | |||||||||||||||||||||||||||
| 474 | $self->percent, | ||||||||||||||||||||||||||||
| 475 | $self->time, | ||||||||||||||||||||||||||||
| 476 | $self->performance, | ||||||||||||||||||||||||||||
| 477 | $self->timePerStep, | ||||||||||||||||||||||||||||
| 478 | ); | ||||||||||||||||||||||||||||
| 479 | } | ||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||
| 481 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||
| 483 | =head2 Meldung generieren | ||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||
| 485 | =head3 msg() - Erzeuge Fortschrittsmeldung | ||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||
| 487 | =head4 Synopsis | ||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||
| 489 | $str = $pi->msg; | ||||||||||||||||||||||||||||
| 490 | $str = $pi->msg($fmt,@args); | ||||||||||||||||||||||||||||
| 491 | $str = $pi->msg($i,$fmt,@args); | ||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||
| 493 | =head4 Arguments | ||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||
| 495 | =over 4 | ||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||
| 497 | =item $i | ||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||
| 499 | Setze Objekt auf Schritt $i. Ist $i nicht angegeben, wird kein neuer | ||||||||||||||||||||||||||||
| 500 | Schritt gesetzt, sondern die Information des aktuellen Schritts in | ||||||||||||||||||||||||||||
| 501 | die Meldung eingesetzt. | ||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||
| 503 | =item $fmt | ||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||
| 505 | Formatelement für sprintf(), erweitert um folgende Platzhalter: | ||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||
| 507 | =over 4 | ||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||
| 509 | =item i/n | ||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||
| 511 | Wert von $pi->count. | ||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||
| 513 | =item x% | ||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||
| 515 | Wert von $pi->percent. | ||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||
| 517 | =item t/t(t) | ||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||
| 519 | Wert von $pi->time. | ||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||
| 521 | =item x/s | ||||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||
| 523 | Wert von $pi->performance. | ||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||
| 525 | =item x/h | ||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||
| 527 | Wert von $pi->performance*3600. | ||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||
| 529 | =item t/1 | ||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||
| 531 | Wert von $pi->timePerStep. | ||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||
| 533 | =back | ||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||
| 535 | Beginnt $fmt mit einem Doppelpunkt (:) werden alle obigen Formatelemente | ||||||||||||||||||||||||||||
| 536 | an den Anfang gesetzt. Beispiel: | ||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||
| 538 | $pi->msg($i,': %s',$name); | ||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||
| 540 | =item @args | ||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||
| 542 | Ausgabe-Zeichenketten oder Argumente für sprintf-Platzhalter. | ||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||
| 544 | =back | ||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||
| 546 | =head4 Returns | ||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||
| 548 | =over 4 | ||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||
| 550 | =item $str | ||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||
| 552 | Erzeugte Meldung | ||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||
| 554 | =back | ||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||
| 556 | =head4 Description | ||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||
| 558 | Erzeuge eine Fortschrittsmeldung und liefere diese zurück. | ||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||
| 560 | Die Methode ist für die eine einzeilige Ausgabe konzipiert, die | ||||||||||||||||||||||||||||
| 561 | sich kontnuierlich überschreibt, bis das Ende der Verarbeitung | ||||||||||||||||||||||||||||
| 562 | erreicht ist. Die letzte Meldung bleibt stehen. | ||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||
| 564 | =over 4 | ||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||
| 566 | =item 1. | ||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||
| 568 | Die erste Form (ohne Parameter) liefert die beim letzten | ||||||||||||||||||||||||||||
| 569 | Aufruf produzierte Meldung - allerdings mit neu berechneten | ||||||||||||||||||||||||||||
| 570 | Durchschittswerten - noch einmal mit "\n" am Zeilenende. | ||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||
| 572 | =item 2. | ||||||||||||||||||||||||||||
| 573 | |||||||||||||||||||||||||||||
| 574 | Die zweite Form erzeugt die Meldung für den aktuellen Schritt | ||||||||||||||||||||||||||||
| 575 | und beendet sie mit "\r". | ||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||
| 577 | =item 3. | ||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||
| 579 | Die dritte Form bewirkt dasselbe wie 2), nur dass zuvor das | ||||||||||||||||||||||||||||
| 580 | Objekt auf Schritt $i gesetzt wird. | ||||||||||||||||||||||||||||
| 581 | |||||||||||||||||||||||||||||
| 582 | =back | ||||||||||||||||||||||||||||
| 583 | |||||||||||||||||||||||||||||
| 584 | Ist bislang kein Schritt ausgeführt worden, liefert die Methode einen | ||||||||||||||||||||||||||||
| 585 | Leerstring (""). | ||||||||||||||||||||||||||||
| 586 | |||||||||||||||||||||||||||||
| 587 | =cut | ||||||||||||||||||||||||||||
| 588 | |||||||||||||||||||||||||||||
| 589 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||
| 591 | 23 | ▶ | sub msg { | ||||||||||||||||||||||||||
|
Subroutine
msg: called CC=10 SCAR=23.5
Pod
documented
| |||||||||||||||||||||||||||||
| 592 | 23 | my $self = shift; | |||||||||||||||||||||||||||
| 593 | |||||||||||||||||||||||||||||
| 594 | # Step setzen, wenn angegeben | ||||||||||||||||||||||||||||
| 595 | |||||||||||||||||||||||||||||
| 596 | 23 | ▶ | if (@_ && $_[0] =~ /^\d+$/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@_ and $_[0] =~ /^\d+$/
MC/DC100%2/2
@_ and $_[0] =~ /^\d+$/
@_
$_[0] =~ /^\d+$/
Truth table100%3/3
A and B
A= @_B= $_[0] =~ /^\d+$/
| |||||||||||||||||||||||||||||
| 597 | 11 | $self->step(shift); | |||||||||||||||||||||||||||
| 598 | } | ||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||
| 600 | # Meldung erzeugen | ||||||||||||||||||||||||||||
| 601 | |||||||||||||||||||||||||||||
| 602 | 23 | my $msg = ''; | |||||||||||||||||||||||||||
| 603 | 23 | ▶ | if (!$self->{'show'}) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 604 | # Keine Meldung | ||||||||||||||||||||||||||||
| 605 | } | ||||||||||||||||||||||||||||
| 606 | elsif (@_) { | ||||||||||||||||||||||||||||
| 607 | 22 | my $fmt = shift; | |||||||||||||||||||||||||||
| 608 | # @_: sprintf-Argumente | ||||||||||||||||||||||||||||
| 609 | |||||||||||||||||||||||||||||
| 610 | # Alle Formatelemente einsetzen, wenn $fmt mit | ||||||||||||||||||||||||||||
| 611 | # einem Doppelpunkt (:) beginnt | ||||||||||||||||||||||||||||
| 612 | |||||||||||||||||||||||||||||
| 613 | 22 | ▶ | if (substr($fmt,0,1) eq ':') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 614 | 0 | $fmt = "i/n x% t/t(t) x/h x/s t/1$fmt"; | |||||||||||||||||||||||||||
| 615 | } | ||||||||||||||||||||||||||||
| 616 | |||||||||||||||||||||||||||||
| 617 | # Format sichern (für $pro->msg ohne Parameter) | ||||||||||||||||||||||||||||
| 618 | |||||||||||||||||||||||||||||
| 619 | 22 | $fmt =~ s/x%/x%%/g; | |||||||||||||||||||||||||||
| 620 | 22 | $self->{'fmt'} = sprintf $fmt,@_; | |||||||||||||||||||||||||||
| 621 | 22 | $fmt =~ s/x%%/x%/g; | |||||||||||||||||||||||||||
| 622 | |||||||||||||||||||||||||||||
| 623 | 22 | my $l0 = length $self->{'msg'}; | |||||||||||||||||||||||||||
| 624 | |||||||||||||||||||||||||||||
| 625 | 22 | my $percent = $self->percent; | |||||||||||||||||||||||||||
| 626 | 22 | ▶ | if ($percent eq '') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 627 | 0 | $fmt =~ s|\s*x%||; # Prozentsatz unterdrücken | |||||||||||||||||||||||||||
| 628 | } | ||||||||||||||||||||||||||||
| 629 | else { | ||||||||||||||||||||||||||||
| 630 | 22 | $fmt =~ s|x%|$self->percent.'%%'|e; | |||||||||||||||||||||||||||
| 631 | } | ||||||||||||||||||||||||||||
| 632 | 22 | $fmt =~ s|i/n|$self->count|e; | |||||||||||||||||||||||||||
| 633 | 22 | $fmt =~ s|t/t\(t\)|$self->time|e; | |||||||||||||||||||||||||||
| 634 | 22 | $fmt =~ s|x/s|$self->performance.'/s'|e; | |||||||||||||||||||||||||||
| 635 | 22 | $fmt =~ s|x/h|($self->performance*3600).'/h'|e; | |||||||||||||||||||||||||||
| 636 | 0 | $fmt =~ s|t/1|$self->timePerStep.'/1'|e; | |||||||||||||||||||||||||||
| 637 | |||||||||||||||||||||||||||||
| 638 | 22 | $msg = sprintf $fmt,@_; | |||||||||||||||||||||||||||
| 639 | |||||||||||||||||||||||||||||
| 640 | 22 | my $eol = "\r"; | |||||||||||||||||||||||||||
| 641 | 22 | ▶ | if ($msg =~ s/(\n+)$//) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 642 | # Ausgabe endet mit \n, wir setzen kein "\r" ans Ende, | ||||||||||||||||||||||||||||
| 643 | # nutzen aber die Überschreibung längerer Zeilen. | ||||||||||||||||||||||||||||
| 644 | |||||||||||||||||||||||||||||
| 645 | 0 | $self->{'msg'} = ''; | |||||||||||||||||||||||||||
| 646 | 0 | $eol = $1; | |||||||||||||||||||||||||||
| 647 | } | ||||||||||||||||||||||||||||
| 648 | else { | ||||||||||||||||||||||||||||
| 649 | 22 | $self->{'msg'} = $msg; | |||||||||||||||||||||||||||
| 650 | } | ||||||||||||||||||||||||||||
| 651 | |||||||||||||||||||||||||||||
| 652 | # Überstehenden Text längerer Zeilen mit Leerzeichen überschreiben | ||||||||||||||||||||||||||||
| 653 | |||||||||||||||||||||||||||||
| 654 | 22 | my $l = length $msg; | |||||||||||||||||||||||||||
| 655 | 22 | ▶ | if ($l < $l0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 656 | # Meldung mit Leerzeichen auffüllen, wenn vorige Meldung | ||||||||||||||||||||||||||||
| 657 | # länger war, damit überzählige Zeichen überschrieben werden. | ||||||||||||||||||||||||||||
| 658 | 3 | $msg .= ' ' x ($l0-$l+1); | |||||||||||||||||||||||||||
| 659 | } | ||||||||||||||||||||||||||||
| 660 | 22 | $msg .= $eol; | |||||||||||||||||||||||||||
| 661 | } | ||||||||||||||||||||||||||||
| 662 | else { | ||||||||||||||||||||||||||||
| 663 | # Wir berechnen die letzte Ausgabe auf Basis des Format-Strings | ||||||||||||||||||||||||||||
| 664 | # neu und berücksichtigen auf dem Weg die Laufzeit des | ||||||||||||||||||||||||||||
| 665 | # letzten Schritts. | ||||||||||||||||||||||||||||
| 666 | |||||||||||||||||||||||||||||
| 667 | 1 | my $fmt = $self->{'fmt'}; | |||||||||||||||||||||||||||
| 668 | 1 | ▶ | if ($fmt ne '') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 669 | 1 | $msg = $self->msg($self->{'i'},$fmt); | |||||||||||||||||||||||||||
| 670 | 1 | $msg =~ s/\r/\n/g; | |||||||||||||||||||||||||||
| 671 | } | ||||||||||||||||||||||||||||
| 672 | } | ||||||||||||||||||||||||||||
| 673 | |||||||||||||||||||||||||||||
| 674 | 23 | return $msg; | |||||||||||||||||||||||||||
| 675 | } | ||||||||||||||||||||||||||||
| 676 | |||||||||||||||||||||||||||||
| 677 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 678 | |||||||||||||||||||||||||||||
| 679 | =head3 warn() - Erzeuge Warnung | ||||||||||||||||||||||||||||
| 680 | |||||||||||||||||||||||||||||
| 681 | =head4 Synopsis | ||||||||||||||||||||||||||||
| 682 | |||||||||||||||||||||||||||||
| 683 | $str = $pi->warn(@args); | ||||||||||||||||||||||||||||
| 684 | $str = $pi->warn($fmt,@args); | ||||||||||||||||||||||||||||
| 685 | |||||||||||||||||||||||||||||
| 686 | =head4 Arguments | ||||||||||||||||||||||||||||
| 687 | |||||||||||||||||||||||||||||
| 688 | =over 4 | ||||||||||||||||||||||||||||
| 689 | |||||||||||||||||||||||||||||
| 690 | =item $fmt | ||||||||||||||||||||||||||||
| 691 | |||||||||||||||||||||||||||||
| 692 | Formatelement für sprintf(). | ||||||||||||||||||||||||||||
| 693 | |||||||||||||||||||||||||||||
| 694 | =item @args | ||||||||||||||||||||||||||||
| 695 | |||||||||||||||||||||||||||||
| 696 | Ausgabe-Zeichenketten oder Argumente für sprintf-Platzhalter. | ||||||||||||||||||||||||||||
| 697 | |||||||||||||||||||||||||||||
| 698 | =back | ||||||||||||||||||||||||||||
| 699 | |||||||||||||||||||||||||||||
| 700 | =head4 Returns | ||||||||||||||||||||||||||||
| 701 | |||||||||||||||||||||||||||||
| 702 | =over 4 | ||||||||||||||||||||||||||||
| 703 | |||||||||||||||||||||||||||||
| 704 | =item $str | ||||||||||||||||||||||||||||
| 705 | |||||||||||||||||||||||||||||
| 706 | Erzeugte Meldung | ||||||||||||||||||||||||||||
| 707 | |||||||||||||||||||||||||||||
| 708 | =back | ||||||||||||||||||||||||||||
| 709 | |||||||||||||||||||||||||||||
| 710 | =head4 Example | ||||||||||||||||||||||||||||
| 711 | |||||||||||||||||||||||||||||
| 712 | Schreibe Warnung nach STDERR, die oberhalb der Fortschrittsanzeige | ||||||||||||||||||||||||||||
| 713 | erscheint: | ||||||||||||||||||||||||||||
| 714 | |||||||||||||||||||||||||||||
| 715 | warn $pro->warn("WARNING: Pfad erfüllt Regex nicht: $file"); | ||||||||||||||||||||||||||||
| 716 | |||||||||||||||||||||||||||||
| 717 | =cut | ||||||||||||||||||||||||||||
| 718 | |||||||||||||||||||||||||||||
| 719 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 720 | |||||||||||||||||||||||||||||
| 721 | 0 | ▶ | sub warn { | ||||||||||||||||||||||||||
|
Subroutine
warn: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 722 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 723 | # @_: @args -or- $fmt,@args | ||||||||||||||||||||||||||||
| 724 | |||||||||||||||||||||||||||||
| 725 | # Meldung erzeugen | ||||||||||||||||||||||||||||
| 726 | |||||||||||||||||||||||||||||
| 727 | 0 | my $msg = ''; | |||||||||||||||||||||||||||
| 728 | 0 | ▶ | if (!$self->{'show'}) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 729 | # Keine Meldung | ||||||||||||||||||||||||||||
| 730 | } | ||||||||||||||||||||||||||||
| 731 | elsif (@_) { | ||||||||||||||||||||||||||||
| 732 | 0 | my $fmt = shift; | |||||||||||||||||||||||||||
| 733 | # @_: sprintf-Argumente | ||||||||||||||||||||||||||||
| 734 | |||||||||||||||||||||||||||||
| 735 | 0 | my $l0 = length $self->{'msg'}; | |||||||||||||||||||||||||||
| 736 | 0 | $msg = sprintf $fmt,@_; | |||||||||||||||||||||||||||
| 737 | |||||||||||||||||||||||||||||
| 738 | # Überstehenden Text längerer Zeilen mit Leerzeichen überschreiben | ||||||||||||||||||||||||||||
| 739 | |||||||||||||||||||||||||||||
| 740 | 0 | $msg =~ s/\n+//; | |||||||||||||||||||||||||||
| 741 | 0 | my $l = length $msg; | |||||||||||||||||||||||||||
| 742 | 0 | ▶ | if ($l < $l0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 743 | # Meldung mit Leerzeichen auffüllen, wenn vorige Meldung | ||||||||||||||||||||||||||||
| 744 | # länger war, damit überzählige Zeichen überschrieben werden. | ||||||||||||||||||||||||||||
| 745 | 0 | $msg .= ' ' x ($l0-$l+1); | |||||||||||||||||||||||||||
| 746 | } | ||||||||||||||||||||||||||||
| 747 | 0 | $msg .= "\n"; | |||||||||||||||||||||||||||
| 748 | } | ||||||||||||||||||||||||||||
| 749 | |||||||||||||||||||||||||||||
| 750 | 0 | return $msg; | |||||||||||||||||||||||||||
| 751 | } | ||||||||||||||||||||||||||||
| 752 | |||||||||||||||||||||||||||||
| 753 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 754 | |||||||||||||||||||||||||||||
| 755 | =head1 VERSION | ||||||||||||||||||||||||||||
| 756 | |||||||||||||||||||||||||||||
| 757 | 1.240 | ||||||||||||||||||||||||||||
| 758 | |||||||||||||||||||||||||||||
| 759 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 760 | |||||||||||||||||||||||||||||
| 761 | Frank Seitz, L<http://fseitz.de/> | ||||||||||||||||||||||||||||
| 762 | |||||||||||||||||||||||||||||
| 763 | =head1 COPYRIGHT | ||||||||||||||||||||||||||||
| 764 | |||||||||||||||||||||||||||||
| 765 | Copyright (C) 2026 Frank Seitz | ||||||||||||||||||||||||||||
| 766 | |||||||||||||||||||||||||||||
| 767 | =head1 LICENSE | ||||||||||||||||||||||||||||
| 768 | |||||||||||||||||||||||||||||
| 769 | This code is free software; you can redistribute it and/or modify | ||||||||||||||||||||||||||||
| 770 | it under the same terms as Perl itself. | ||||||||||||||||||||||||||||
| 771 | |||||||||||||||||||||||||||||
| 772 | =cut | ||||||||||||||||||||||||||||
| 773 | |||||||||||||||||||||||||||||
| 774 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 775 | |||||||||||||||||||||||||||||
| 776 | 16 | 1; | |||||||||||||||||||||||||||
| 777 | |||||||||||||||||||||||||||||
| 778 | # eof | ||||||||||||||||||||||||||||