OsPerfState saves for all CPUs
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
#include <map>
|
||||
|
||||
#ifdef __linux__
|
||||
#include "detail/os/linux.hpp"
|
||||
@@ -17,19 +18,23 @@ namespace perfect {
|
||||
|
||||
struct OsPerfState {
|
||||
#ifdef __linux__
|
||||
std::string governor;
|
||||
std::map<int, std::string> governors;
|
||||
#else
|
||||
#error "unsupported platform"
|
||||
#endif
|
||||
};
|
||||
|
||||
Result get_os_perf_state(OsPerfState *state, const int cpu) {
|
||||
assert(state);
|
||||
Result get_os_perf_state(OsPerfState &state) {
|
||||
#ifdef __linux__
|
||||
return get_governor(state->governor, cpu);
|
||||
for (auto cpu : cpus()) {
|
||||
std::string gov;
|
||||
PERFECT_SUCCESS_OR_RETURN(get_governor(gov, cpu));
|
||||
state.governors[cpu] = gov;
|
||||
}
|
||||
#else
|
||||
#error "unsupported platform"
|
||||
#endif
|
||||
return Result::SUCCESS;
|
||||
}
|
||||
|
||||
Result os_perf_state_maximum(const int cpu) {
|
||||
@@ -48,13 +53,15 @@ Result os_perf_state_minimum(const int cpu) {
|
||||
#endif
|
||||
}
|
||||
|
||||
Result set_os_perf_state(const int cpu, OsPerfState state) {
|
||||
#ifdef __linux__
|
||||
return set_governor(cpu, state.governor);
|
||||
Result set_os_perf_state(OsPerfState state) {
|
||||
#ifdef __linux__
|
||||
for (auto kv : state.governors) {
|
||||
PERFECT_SUCCESS_OR_RETURN(set_governor(kv.first, kv.second));
|
||||
}
|
||||
#else
|
||||
#error "unsupported platform"
|
||||
#endif
|
||||
|
||||
return Result::SUCCESS;
|
||||
}
|
||||
|
||||
};
|
Reference in New Issue
Block a user