eslint
This commit is contained in:
@ -3,27 +3,27 @@ var os = require("os");
|
||||
//Create function to get CPU information
|
||||
function cpuAverage() {
|
||||
|
||||
//Initialise sum of idle and time of cores and fetch CPU info
|
||||
let totalIdle = 0, totalTick = 0;
|
||||
const cpus = os.cpus();
|
||||
//Initialise sum of idle and time of cores and fetch CPU info
|
||||
let totalIdle = 0, totalTick = 0;
|
||||
const cpus = os.cpus();
|
||||
|
||||
//Loop through CPU cores
|
||||
for(let i = 0, len = cpus.length; i < len; i++) {
|
||||
//Loop through CPU cores
|
||||
for(let i = 0, len = cpus.length; i < len; i++) {
|
||||
|
||||
//Select CPU core
|
||||
const cpu = cpus[i];
|
||||
//Select CPU core
|
||||
const cpu = cpus[i];
|
||||
|
||||
//Total up the time in the cores tick
|
||||
for(const type in cpu.times) {
|
||||
totalTick += cpu.times[type];
|
||||
}
|
||||
//Total up the time in the cores tick
|
||||
for(const type in cpu.times) {
|
||||
totalTick += cpu.times[type];
|
||||
}
|
||||
|
||||
//Total up the idle time of the core
|
||||
totalIdle += cpu.times.idle;
|
||||
}
|
||||
//Total up the idle time of the core
|
||||
totalIdle += cpu.times.idle;
|
||||
}
|
||||
|
||||
//Return the average Idle and Tick times
|
||||
return {idle: totalIdle / cpus.length, total: totalTick / cpus.length};
|
||||
//Return the average Idle and Tick times
|
||||
return {idle: totalIdle / cpus.length, total: totalTick / cpus.length};
|
||||
}
|
||||
|
||||
//Grab first CPU Measure
|
||||
@ -33,16 +33,16 @@ let percentageCPU = 0
|
||||
//Set delay for second Measure
|
||||
const cpuTimer = setInterval(function() {
|
||||
|
||||
//Grab second Measure
|
||||
const endMeasure = cpuAverage();
|
||||
//Grab second Measure
|
||||
const endMeasure = cpuAverage();
|
||||
|
||||
//Calculate the difference in idle and total time between the measures
|
||||
const idleDifference = endMeasure.idle - startMeasure.idle;
|
||||
const totalDifference = endMeasure.total - startMeasure.total;
|
||||
//Calculate the difference in idle and total time between the measures
|
||||
const idleDifference = endMeasure.idle - startMeasure.idle;
|
||||
const totalDifference = endMeasure.total - startMeasure.total;
|
||||
|
||||
//Calculate the average percentage CPU usage
|
||||
percentageCPU = 100 - ~~(100 * idleDifference / totalDifference);
|
||||
startMeasure = endMeasure
|
||||
//Calculate the average percentage CPU usage
|
||||
percentageCPU = 100 - ~~(100 * idleDifference / totalDifference);
|
||||
startMeasure = endMeasure
|
||||
|
||||
}, 300);
|
||||
|
||||
|
@ -33,7 +33,7 @@ function generateTid() {
|
||||
class Spider extends Emiter {
|
||||
constructor(client) {
|
||||
super()
|
||||
const options = arguments.length? arguments[0]: {}
|
||||
const options = arguments.length ? arguments[0] : {}
|
||||
this.table = new Table(options.tableCaption || 1000)
|
||||
this.bootstraps = options.bootstraps || bootstraps
|
||||
this.token = new Token()
|
||||
|
@ -3,7 +3,7 @@
|
||||
module.exports = class {
|
||||
constructor() {
|
||||
this.generate()
|
||||
const it = setInterval(() => this.generate(), 60000*15)
|
||||
const it = setInterval(() => this.generate(), 60000 * 15)
|
||||
it.unref()
|
||||
}
|
||||
|
||||
@ -12,6 +12,6 @@ module.exports = class {
|
||||
}
|
||||
|
||||
generate() {
|
||||
this.token = new Buffer([parseInt(Math.random()*200), parseInt(Math.random()*200)])
|
||||
this.token = new Buffer([parseInt(Math.random() * 200), parseInt(Math.random() * 200)])
|
||||
}
|
||||
}
|
@ -24,7 +24,7 @@ let connectTracker = function(connection) {
|
||||
debug('start screape connection');
|
||||
let buffer = new Buffer(16);
|
||||
|
||||
const transactionId = Math.floor((Math.random()*100000)+1);
|
||||
const transactionId = Math.floor((Math.random() * 100000) + 1);
|
||||
|
||||
buffer.fill(0);
|
||||
|
||||
|
Reference in New Issue
Block a user