SystemKit
SystemKit copied to clipboard
Energy API
- As seen in Activity Monitor
- Seems to be a custom calculation, no API for it
- Maybe something in IOPMLib
Goodies via class-dump on Activity Monitor:
NSNumberFormatter *_powerScoreFormatter;
NSNumber *_combinedPowerScore;
NSNumber *_combinedAveragePowerScore;
NSNumber *_averagePowerScore;
NSNumber *_powerScore;
NSNumber *_totalPowerScore;
NSString *_combinedPowerScoreDescription;
NSString *_combinedAveragePowerScoreDescription;
NSString *_powerScoreDescription;
NSString *_averagePowerScoreDescription;
@property(retain) NSString *averagePowerScoreDescription; // @synthesize averagePowerScoreDescription=_averagePowerScoreDescription;
@property(retain) NSString *powerScoreDescription; // @synthesize powerScoreDescription=_powerScoreDescription;
@property(retain) NSString *combinedAveragePowerScoreDescription; // @synthesize combinedAveragePowerScoreDescription=_combinedAveragePowerScoreDescription;
@property(retain) NSString *combinedPowerScoreDescription; // @synthesize combinedPowerScoreDescription=_combinedPowerScoreDescription;
@property(retain) NSNumber *totalPowerScore; // @synthesize totalPowerScore=_totalPowerScore;
@property(retain) NSNumber *powerScore; // @synthesize powerScore=_powerScore;
@property(retain) NSNumber *averagePowerScore; // @synthesize averagePowerScore=_averagePowerScore;
@property(retain) NSNumber *combinedAveragePowerScore; // @dynamic combinedAveragePowerScore;
@property(retain) NSNumber *combinedPowerScore; // @dynamic combinedPowerScore;
- (id)initWithName:(id)arg1 powerScore:(id)arg2 icon:(id)arg3 bundeIdentifier:(id)arg4;
Next - try DTrace & LLDB/GDB.
Looks like top (which is open source) actually has this stat already, didn't notice it. :)
Also, pre-req for this is #10.
These don't seem to be used by top. Will try them out. In <mach/task_info.h>
#define TASK_POWER_INFO_V2 26
typedef struct {
uint64_t task_gpu_utilisation;
uint64_t task_gpu_stat_reserved0;
uint64_t task_gpu_stat_reserved1;
uint64_t task_gpu_stat_reserved2;
} gpu_energy_data;
typedef gpu_energy_data *gpu_energy_data_t;
struct task_power_info_v2 {
task_power_info_data_t cpu_energy;
gpu_energy_data gpu_energy;
};
typedef struct task_power_info_v2 task_power_info_v2_data_t;
typedef struct task_power_info_v2 *task_power_info_v2_t;
#define TASK_POWER_INFO_V2_COUNT ((mach_msg_type_number_t) \
(sizeof (task_power_info_v2_data_t) / sizeof (natural_t)))
TASK_POWER_INFO_V2
didn't return any GPU data. Probably because my machine is old, newer graphics card needed, likely a discrete one - MacBook Pro 15+ & Mac Pro.