Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export async function legacyJsonOutput(results: BenchmarkResult[]):
Promise {
// TODO Add git info.
const battery = await systeminformation.battery();
const cpu = await systeminformation.cpu();
const currentLoad = await systeminformation.currentLoad();
const memory = await systeminformation.mem();
return {
benchmarks: results,
datetime: new Date().toISOString(),
system: {
cpu: {
manufacturer: cpu.manufacturer,
model: cpu.model,
family: cpu.family,
speed: cpu.speed,
cores: cpu.cores,
},
load: {
average: currentLoad.avgload,
current: currentLoad.currentload,
},
battery: {
async setup() {
const [
graphics,
os,
cpu,
mem,
online,
] = await Promise.all([
si.graphics(),
si.osInfo(),
si.cpu(),
si.mem(),
isOnline(),
])
this._graphics = graphics
this.os = os
this.cpu = cpu
this.memory = mem
this.online = online
logger.info(`GPU devices: ${this.graphics.length}`)
logger.info(`RAM: ${this.memory.total} bytes.`)
logger.info(`Internet connection: ${this.online}`)
logger.debug(this)
}
private async getEncryptionKey(): Promise {
const s = await system();
const c = await cpu();
const m = await mem();
const o = await osInfo();
return s.manufacturer + ';' + s.uuid + ';' + String(c.processors) + ';'
+ c.vendor + ';' + m.total + ';' + o.platform + ';' + o.release;
}
mounted() {
si.mem(ram => {
let totalMem = helpers.prettyMemSize(ram.total)
let totalSwap = helpers.prettyMemSize(ram.swaptotal)
for (var i = 0; i < 2; i++)
this.memoryValues.push((new Array(seconds_max)).fill(0))
let memoryChart = new Chartkick.LineChart('memory-chart', this.memoryData, {
colors: ['#2ecc71', '#e74c3c', '#3498db', '#f1c40f', '#9b59b6', '#34495e', '#1abc9c', '#e67e22'],
min: 0,
max: Math.max(totalMem, totalSwap),
legend: true,
points: false
})
setInterval(() => {
si.mem(ram => {
const ramInfo = async () => {
const ram = await si.mem()
return {
total: bytesToSize(ram.total),
used: bytesToSize(ram.active),
free: bytesToSize(ram.available)
}
}
setInterval(() => {
si.mem(ram => {
let usedMem = ram.total - ram.available
let totalMem = ram.total
this.memoryValue = helpers.prettyMemSize(usedMem) + ' / ' + helpers.prettyMemSize(totalMem) + 'GB'
memoryBar.animate(usedMem / totalMem)
})
}, 1500)
}
async setup() {
const [
graphics,
cpu,
mem,
online,
] = await Promise.all([
si.graphics(),
si.cpu(),
si.mem(),
isOnline(),
])
this._graphics = graphics
this._cpu = cpu
this._memory = mem
this.online = online
}
function checkMemory() {
return sysinfo.mem().then((memoryInfo) => {
const availableMemory = memoryInfo.available / MB_IN_BYTES;
if (availableMemory < MIN_MEMORY) {
return Promise.reject(new SystemError(`You are recommended to have at least ${MIN_MEMORY} MB of memory available for smooth operation. It looks like you have ~${parseInt(availableMemory)} MB available.`));
}
return Promise.resolve();
});
}