32 lines
959 B
Objective-C
32 lines
959 B
Objective-C
#ifndef MMCPULoadProvider_h
|
|
#define MMCPULoadProvider_h
|
|
|
|
#import <Foundation/Foundation.h>
|
|
#import <mach/mach.h>
|
|
#import <mach/processor_info.h>
|
|
#import "MMTelemetryProvider.h"
|
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
/**
|
|
* MMCPULoadProvider
|
|
* Samples real-time Mach host processor CPU load ticks, per-core utilization percentages,
|
|
* and CPU operating frequency.
|
|
*/
|
|
@interface MMCPULoadProvider : NSObject <MMTelemetryProvider>
|
|
|
|
@property (nonatomic, readonly) natural_t coreCount;
|
|
|
|
/**
|
|
* Static calculator method facilitating deterministic unit testing with mock tick data.
|
|
*/
|
|
+ (NSDictionary<NSString *, id> *)calculateLoadFromPreviousTicks:(const struct processor_cpu_load_info * _Nullable)prevTicks
|
|
currentTicks:(const struct processor_cpu_load_info *)currTicks
|
|
coreCount:(natural_t)coreCount;
|
|
|
|
@end
|
|
|
|
NS_ASSUME_NONNULL_END
|
|
|
|
#endif /* MMCPULoadProvider_h */
|