LCOV - code coverage report

Current view
top level - src/worker - worker.stats.dart
Test
lcov.info
Date
2026-03-04
Legend
Lines
hit
not hit
Branches
taken
not taken
# not executed
HitTotalCoverage
Lines3535100.0%
Functions00-
Branches00-
Each row represents a line of source code
LineBranchHitsSource code
1part of 'worker.dart';
2
3class _Stats {
411 _Stats(Worker w)
511 : _idle = Timestamp.now(),
6 _worker = w;
7
8 final Worker _worker;
9
1010 void start() {
1130 _idle = _started = Timestamp.now();
12 }
13
1411 void stop() {
1522 _stopped = Timestamp.now();
16 }
17
1810 void beginWork() {
1920 _workload++;
2030 if (_workload > _maxWorkload) {
2120 _maxWorkload = _workload;
22 }
23 }
24
2510 void endWork([dynamic _]) {
2620 _workload--;
2720 _totalWorkload++;
2820 if (_workload == 0) {
2920 _idle = Timestamp.now();
30 }
31 }
32
334 void failed() {
348 _totalErrors++;
35 }
36
37 /// Start timestamp
38 Timestamp? _started;
39
40 /// Stopped timestamp
41 Timestamp? _stopped;
42
43 /// Idle timestamp.
44 Timestamp _idle;
45
46 /// Current workload.
47 int _workload = 0;
48
49 /// Maximum acceptable workload.
50 int _maxWorkload = 0;
51
52 /// Total processed workload.
53 int _totalWorkload = 0;
54
55 /// Total errors.
56 int _totalErrors = 0;
57
586 Duration _getUpTime(Timestamp timestamp) =>
5918 (_started == null) ? Duration.zero : timestamp.elapsedSince(_started!);
60
616 Duration _getIdleTime(Timestamp timestamp) =>
6224 (_workload > 0) ? Duration.zero : timestamp.elapsedSince(_idle);
63
64 /// Indicates if the [Worker] has been stopped.
6522 bool get isStopped => _stopped != null;
66
676 WorkerStat get snapshot {
686 final ts = Timestamp.now();
696 return WorkerStatImpl.create(
7012 _worker.runtimeType,
7112 _worker.hashCode,
726 isStopped,
736 _workload,
746 _maxWorkload,
756 _totalWorkload,
766 _totalErrors,
7712 _getUpTime(_stopped ?? ts),
786 _getIdleTime(ts),
7918 _worker._channel?.getActiveConnections() ?? 0,
80 );
81 }
82}
Choose Features