@@ -12,33 +12,33 @@ import QuartzCore
12
12
let TASK_VM_INFO_COUNT = mach_msg_type_number_t ( MemoryLayout < task_vm_info_data_t > . size / MemoryLayout < integer_t > . size)
13
13
let TASK_VM_INFO_REV1_COUNT = mach_msg_type_number_t ( MemoryLayout . offset ( of: \task_vm_info_data_t . min_address) ! / MemoryLayout< integer_t> . size)
14
14
15
- internal enum MachError : Error {
15
+ public enum MachError : Error {
16
16
case task_info( return: kern_return_t )
17
17
case task_threads( return: kern_return_t )
18
18
case thread_info( return: kern_return_t )
19
19
}
20
20
21
21
/// Aggregate metric values and compute `min`, `max`, `sum`, `avg`, and `count`.
22
- internal class MetricAggregator < T> where T: Numeric {
23
- internal struct Aggregation {
24
- let min : T
25
- let max : T
26
- let sum : T
27
- let count : Int
28
- let avg : Double
22
+ public class MetricAggregator < T> where T: Numeric {
23
+ public struct Aggregation {
24
+ public let min : T
25
+ public let max : T
26
+ public let sum : T
27
+ public let count : Int
28
+ public let avg : Double
29
29
}
30
30
31
31
private var mutex = pthread_mutex_t ( )
32
32
private var _aggregation : Aggregation ?
33
33
34
- var aggregation : Aggregation ? {
34
+ public var aggregation : Aggregation ? {
35
35
pthread_mutex_lock ( & mutex)
36
36
defer { pthread_mutex_unlock ( & mutex) }
37
37
return _aggregation
38
38
}
39
39
40
40
/// Resets the minimum frame rate to `nil`.
41
- func reset( ) {
41
+ public func reset( ) {
42
42
pthread_mutex_lock ( & mutex)
43
43
_aggregation = nil
44
44
pthread_mutex_unlock ( & mutex)
@@ -53,7 +53,7 @@ extension MetricAggregator where T: BinaryInteger {
53
53
/// Records a `BinaryInteger` value.
54
54
///
55
55
/// - Parameter value: The value to record.
56
- func record( value: T ) {
56
+ public func record( value: T ) {
57
57
pthread_mutex_lock ( & mutex)
58
58
_aggregation = _aggregation. map {
59
59
let sum = $0. sum + value
@@ -74,7 +74,7 @@ extension MetricAggregator where T: BinaryFloatingPoint {
74
74
/// Records a `BinaryFloatingPoint` value.
75
75
///
76
76
/// - Parameter value: The value to record.
77
- func record( value: T ) {
77
+ internal func record( value: T ) {
78
78
pthread_mutex_lock ( & mutex)
79
79
_aggregation = _aggregation. map {
80
80
let sum = $0. sum + value
@@ -94,7 +94,7 @@ extension MetricAggregator where T: BinaryFloatingPoint {
94
94
/// Collect Memory footprint metric.
95
95
///
96
96
/// Based on a timer, the `Memory` aggregator will periodically record the memory footprint.
97
- internal final class Memory : MetricAggregator < Double > {
97
+ public final class Memory : MetricAggregator < Double > {
98
98
/// Dispatch source object for monitoring timer events.
99
99
private let timer : DispatchSourceTimer
100
100
@@ -107,7 +107,7 @@ internal final class Memory: MetricAggregator<Double> {
107
107
/// - queue: The queue on which to execute the timer handler.
108
108
/// - interval: The timer interval, default to 100 ms.
109
109
/// - leeway: The timer leeway, default to 10 ms.
110
- required init (
110
+ public required init (
111
111
queue: DispatchQueue ,
112
112
every interval: DispatchTimeInterval = . milliseconds( 100 ) ,
113
113
leeway: DispatchTimeInterval = . milliseconds( 10 )
@@ -158,7 +158,7 @@ internal final class Memory: MetricAggregator<Double> {
158
158
/// Collect CPU usage metric.
159
159
///
160
160
/// Based on a timer, the `CPU` aggregator will periodically record the CPU usage.
161
- internal final class CPU : MetricAggregator < Double > {
161
+ public final class CPU : MetricAggregator < Double > {
162
162
/// Dispatch source object for monitoring timer events.
163
163
private let timer : DispatchSourceTimer
164
164
@@ -171,7 +171,7 @@ internal final class CPU: MetricAggregator<Double> {
171
171
/// - queue: The queue on which to execute the timer handler.
172
172
/// - interval: The timer interval, default to 100 ms.
173
173
/// - leeway: The timer leeway, default to 10 ms.
174
- init (
174
+ public required init (
175
175
queue: DispatchQueue ,
176
176
every interval: DispatchTimeInterval = . milliseconds( 100 ) ,
177
177
leeway: DispatchTimeInterval = . milliseconds( 10 )
@@ -241,7 +241,7 @@ internal final class CPU: MetricAggregator<Double> {
241
241
}
242
242
243
243
/// Collect Frame rate metric based on ``CADisplayLinker`` timer.
244
- internal final class FPS : MetricAggregator < Int > {
244
+ public final class FPS : MetricAggregator < Int > {
245
245
private class CADisplayLinker {
246
246
weak var fps : FPS ?
247
247
@@ -260,7 +260,7 @@ internal final class FPS: MetricAggregator<Int> {
260
260
261
261
private var displayLink : CADisplayLink
262
262
263
- override init ( ) {
263
+ override public init ( ) {
264
264
let linker = CADisplayLinker ( )
265
265
displayLink = CADisplayLink ( target: linker, selector: #selector( CADisplayLinker . tick ( link: ) ) )
266
266
super. init ( )
0 commit comments