OsPerfState saves for all CPUs
This commit is contained in:
@@ -5,23 +5,20 @@
|
||||
int main(void) {
|
||||
perfect::init();
|
||||
|
||||
std::map<int, perfect::OsPerfState> states;
|
||||
// os performance state for each cpu
|
||||
perfect::OsPerfState state;
|
||||
|
||||
// store the current state
|
||||
PERFECT(perfect::get_os_perf_state(state));
|
||||
|
||||
// max state for each cpu
|
||||
for (auto cpu : perfect::cpus()) {
|
||||
perfect::OsPerfState state;
|
||||
perfect::Result result;
|
||||
result = perfect::get_os_perf_state(&state, cpu);
|
||||
if (perfect::Result::SUCCESS == result) {
|
||||
states[cpu] = state;
|
||||
}
|
||||
perfect::os_perf_state_maximum(cpu);
|
||||
PERFECT(perfect::os_perf_state_maximum(cpu));
|
||||
}
|
||||
|
||||
// do things with all CPUs set to the maximum performancem mode by the OS
|
||||
|
||||
for (auto kv : states) {
|
||||
int cpu = kv.first;
|
||||
perfect::OsPerfState state = kv.second;
|
||||
perfect::set_os_perf_state(cpu, state);
|
||||
}
|
||||
// restore original state
|
||||
PERFECT(perfect::set_os_perf_state(state));
|
||||
|
||||
}
|
Reference in New Issue
Block a user