All Discussions > Steam Forums > Off Topic > Topic Details
nothing to see here
I need to store this code here real quick, cuz I can't be bothered to put it on the cloud

#include <iostream> #include <fstream> #include <string> int read_power_limit(const std::string& path) { std::ifstream file(path); if (!file) { std::cerr << "Failed to read from " << path << "\n"; return -1; } long long microwatts; file >> microwatts; return microwatts / 1000000; // convert µW to W } void set_power_limit(const std::string& path, int watts) { std::ofstream file(path); if (!file) { std::cerr << "Failed to write to " << path << "\n"; return; } file << watts * 1000000; std::cout << "Set " << path << " to " << watts << "W\n"; } int main() { std::string pl1_path = "/sys/class/powercap/intel-rapl:0/constraint_0_power_limit_uw"; std::string pl2_path = "/sys/class/powercap/intel-rapl:0/constraint_1_power_limit_uw"; std::string pl1_input; std::string pl2_input; int pl1 = read_power_limit(pl1_path); int pl2 = read_power_limit(pl2_path); if (pl1 != -1) std::cout << "Current PL1: " << pl1 << "W\n"; if (pl2 != -1) std::cout << "Current PL2: " << pl2 << "W\n"; std::cout << "Enter new PL1 (W): "; std::cin >> pl1_input; if (pl1_input == "x") { std::cout << "Values not changed!\n"; return 0; } std::cout << "Enter new PL2 (W): "; std::cin >> pl2_input; pl1 = std::stoi(pl1_input); pl2 = std::stoi(pl2_input); set_power_limit(pl1_path, pl1); set_power_limit(pl2_path, pl2); std::cout << "Values changed!\n"; return 0; }
< >
Showing 1-3 of 3 comments
I know this means something, but I don’t have the skills to work it out
Houseman 18 Jul @ 2:49pm 
Originally posted by Ice9:
I need to store this code here real quick, cuz I can't be bothered to put it on the cloud

What do you think these servers are?
Originally posted by Ice9:
Nothing to see here.

I need to store this code here real quick, cuz I can't be bothered to put it on the cloud

#include <iostream> #include <fstream> #include <string> int read_power_limit(const std::string& path) { std::ifstream file(path); if (!file) { std::cerr << "Failed to read from " << path << "\n"; return -1; } long long microwatts; file >> microwatts; return microwatts / 1000000; // convert µW to W } void set_power_limit(const std::string& path, int watts) { std::ofstream file(path); if (!file) { std::cerr << "Failed to write to " << path << "\n"; return; } file << watts * 1000000; std::cout << "Set " << path << " to " << watts << "W\n"; } int main() { std::string pl1_path = "/sys/class/powercap/intel-rapl:0/constraint_0_power_limit_uw"; std::string pl2_path = "/sys/class/powercap/intel-rapl:0/constraint_1_power_limit_uw"; std::string pl1_input; std::string pl2_input; int pl1 = read_power_limit(pl1_path); int pl2 = read_power_limit(pl2_path); if (pl1 != -1) std::cout << "Current PL1: " << pl1 << "W\n"; if (pl2 != -1) std::cout << "Current PL2: " << pl2 << "W\n"; std::cout << "Enter new PL1 (W): "; std::cin >> pl1_input; if (pl1_input == "x") { std::cout << "Values not changed!\n"; return 0; } std::cout << "Enter new PL2 (W): "; std::cin >> pl2_input; pl1 = std::stoi(pl1_input); pl2 = std::stoi(pl2_input); set_power_limit(pl1_path, pl1); set_power_limit(pl2_path, pl2); std::cout << "Values changed!\n"; return 0; }

I am doing you the favour of blocking you so any new code is save at least from me.

Others should follow my example to help you out.
< >
Showing 1-3 of 3 comments
Per page: 1530 50

All Discussions > Steam Forums > Off Topic > Topic Details