LCOV - code coverage report

Current view
top level - /src - perf_counter.dart
Test
lcov.info
Date
2022-04-02
Legend
Lines
hit
not hit
Branches
taken
not taken
# not executed
HitTotalCoverage
Lines151693.8%
Functions00-
Branches00-
Each row represents a line of source code
LineBranchHitsSource code
1import 'perf_counter_snapshot.dart';
2
3/// Simple performance counter to consolidate statistics about woker tast execution: total number of calls, total
4/// number of errors, total elapsed time, and max elapsed time.
5class PerfCounter implements PerfCounterSnapshot {
6 /// Creates a performance counter.
71 PerfCounter(this.name)
8 : _maxTimeInMicroseconds = 0,
9 _totalTimeInMicroseconds = 0,
10 _totalCount = 0,
11 _totalErrors = 0;
12
13 /// The counter's name or label.
14 @override
15 final String name;
16
17 /// Maximum elapsed time for a single call, in microseconds.
181 @override
191 int get maxTimeInMicroseconds => _maxTimeInMicroseconds;
20 int _maxTimeInMicroseconds;
21
22 /// Total elapsed time, in microseconds.
231 @override
241 int get totalTimeInMicroseconds => _totalTimeInMicroseconds;
25 int _totalTimeInMicroseconds;
26
27 /// Total number of calls.
281 @override
291 int get totalCount => _totalCount;
30 int _totalCount;
31
32 /// Total number of errors.
331 @override
341 int get totalErrors => _totalErrors;
35 int _totalErrors;
36
37 /// Returns a snapshot of the [PerfCounter]'s values.
382 PerfCounterSnapshot get snapshot => PerfCounterSnapshot(this);
39}
40
41// private implementation internal to Squadron
42extension PerfCounterExt on PerfCounter {
43 /// Updates counter value with the duration indicated by [timeInMicroseconds].
44 /// 1. update the maximum elapsed time if required.
45 /// 2. add specified time to the total elapsed time.
46 /// 3. depending on [success], increment the total number of calls or errors by 1.
471 void update(int timeInMicroseconds, bool success) {
482 if (timeInMicroseconds > _maxTimeInMicroseconds) {
491 _maxTimeInMicroseconds = timeInMicroseconds;
50 }
512 _totalTimeInMicroseconds += timeInMicroseconds;
52 if (success) {
532 _totalCount++;
54 } else {
550 _totalErrors++;
56 }
57 }
58}
Choose Features