2018-10-11 06:11:25 +00:00
|
|
|
const si = require("systeminformation");
|
2018-10-11 06:19:42 +00:00
|
|
|
const mri = require("mri");
|
2018-10-11 06:30:22 +00:00
|
|
|
const sll = require("single-line-log").stdout;
|
|
|
|
const kleur = require("kleur");
|
2018-10-11 06:52:54 +00:00
|
|
|
const isPrime = require("prime-number");
|
|
|
|
const eatCPU = require("./eat-cpu");
|
2018-10-11 06:11:25 +00:00
|
|
|
|
|
|
|
async function readTemp() {
|
|
|
|
const temp = await si.cpuTemperature();
|
2018-10-11 06:30:22 +00:00
|
|
|
return { main: temp.main, cores: temp.cores };
|
2018-10-11 06:11:25 +00:00
|
|
|
}
|
|
|
|
|
2018-10-11 06:19:42 +00:00
|
|
|
async function thawMyCarrots(targetTemp) {
|
2018-10-11 06:52:54 +00:00
|
|
|
let temp = await readTemp(),
|
|
|
|
n = 2;
|
|
|
|
|
|
|
|
while (1) {
|
|
|
|
if (temp.main < targetTemp) {
|
|
|
|
eatCPU(n);
|
|
|
|
n = n + 1;
|
|
|
|
}
|
2018-10-11 06:11:25 +00:00
|
|
|
|
2018-10-11 06:30:22 +00:00
|
|
|
temp = await readTemp();
|
2018-10-11 06:52:54 +00:00
|
|
|
sll(
|
|
|
|
"Current temp",
|
|
|
|
kleur.bold.red(temp.main.toFixed(2)),
|
|
|
|
"\nCores at",
|
|
|
|
kleur.bold.gray(temp.cores),
|
|
|
|
n
|
|
|
|
);
|
2018-10-11 06:11:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-11 06:19:42 +00:00
|
|
|
const args = process.argv.slice(2),
|
|
|
|
targetTemp = mri(args, {
|
|
|
|
alias: { temp: "t" },
|
|
|
|
default: { temp: 85 }
|
|
|
|
});
|
|
|
|
|
|
|
|
thawMyCarrots(targetTemp.temp);
|