LCOV - code coverage report

Current view
top level - src/worker - worker.stats.dart
Test
lcov.info
Date
2026-11-07
Legend
Lines
hit
not hit
Branches
taken
not taken
# not executed
HitTotalCoverage
Lines3939100.0%
Functions00-
Branches00-
Each row represents a line of source code
LineBranchHitsSource code
1part of 'worker.dart';
2
3class _Stats {
41 _Stats(Worker w) : _worker = w {
52 _idleTime.start();
6 }
7
8 final Worker _worker;
9 final _idleTime = Stopwatch();
10 Stopwatch? _upTime;
11 Duration? _initTime;
12
131 void start() {
141 if (_upTime == null) {
153 _initTime = _idleTime.elapsed;
163 _upTime = Stopwatch()..start();
172 _idleTime.reset();
182 _idleTime.start();
19 }
20 }
21
221 void stop() {
231 _initTime ??= Duration.zero;
243 (_upTime ??= Stopwatch()).stop();
25 }
26
271 void beginWork() {
282 _idleTime.stop();
292 _idleTime.reset();
302 _workload++;
313 if (_workload > _maxWorkload) {
322 _maxWorkload = _workload;
33 }
34 }
35
361 void endWork([dynamic _]) {
372 _workload--;
382 _totalWorkload++;
392 if (_workload == 0) {
402 _idleTime.reset();
412 _idleTime.start();
42 }
43 }
44
451 void failed() {
462 _totalErrors++;
47 }
48
49 /// Current workload.
50 int _workload = 0;
51
52 /// Maximum acceptable workload.
53 int _maxWorkload = 0;
54
55 /// Total processed workload.
56 int _totalWorkload = 0;
57
58 /// Total errors.
59 int _totalErrors = 0;
60
61 /// Indicates if the [Worker] has been stopped.
624 bool get isStopped => _upTime?.isRunning == false;
63
641 WorkerStat get snapshot {
65 // measure idle time before up time
662 final idleTime = _idleTime.elapsed;
671 return WorkerStatImpl.create(
682 _worker.runtimeType,
692 _worker.hashCode,
701 isStopped,
711 _workload,
721 _maxWorkload,
731 _totalWorkload,
741 _totalErrors,
751 _initTime,
762 _upTime?.elapsed ?? Duration.zero,
77 idleTime,
783 _worker._channel?.getActiveConnections() ?? 0,
79 );
80 }
81}
Choose Features