LCOV - code coverage report

Current view
top level - src/stats - worker_stat.dart
Test
lcov.info
Date
2025-03-26
Legend
Lines
hit
not hit
Branches
taken
not taken
# not executed
HitTotalCoverage
Lines3650.0%
Functions00-
Branches00-
Each row represents a line of source code
LineBranchHitsSource code
1import 'package:meta/meta.dart';
2
3/// Base statistics for worker.
4class WorkerStat {
511 WorkerStat._(
6 this.workerType,
7 this.workerHashCode,
8 this.isStopped,
9 this.workload,
10 this.maxWorkload,
11 this.totalWorkload,
12 this.totalErrors,
13 this.upTime,
14 this.idleTime);
15
16 /// Timestamp of this snapshot
17 final timestamp = DateTime.now().toUtc();
18
19 /// The worker's runtime type.
20 final Type workerType;
21
22 /// The worker's hashCode.
23 final int workerHashCode;
24
25 /// Worker running flag.
26 final bool isStopped;
27
28 /// Current workload being processed by the worker.
29 final int workload;
30
31 /// Maximum concurrent workload processed by the worker.
32 final int maxWorkload;
33
34 /// Total workload processed by the worker.
35 final int totalWorkload;
36
37 /// Total errors raised during processing.
38 final int totalErrors;
39
40 /// The worker's up-time.
41 Duration upTime;
42
43 /// The worker's idle-time.
44 Duration idleTime;
45}
46
47extension WorkerStatsExt on Iterable<WorkerStat> {
480 int get workload => fold<int>(0, (p, s) => p + s.workload);
490 int get totalWorkload => fold<int>(0, (p, s) => p + s.totalWorkload);
500 int get totalErrors => fold<int>(0, (p, s) => p + s.totalErrors);
51}
52
53@internal
54extension WorkerStatImpl on WorkerStat {
5511 static WorkerStat create(
56 Type workerType,
57 int workerHashCode,
58 bool isStopped,
59 int workload,
60 int maxWorkload,
61 int totalWorkload,
62 int totalErrors,
63 Duration upTime,
64 Duration idleTime) =>
6511 WorkerStat._(workerType, workerHashCode, isStopped, workload, maxWorkload,
66 totalWorkload, totalErrors, upTime, idleTime);
67}
Choose Features