FridayNightFunkinBoyfriendBot/modules/memusage.js

36 lines
1 KiB
JavaScript
Raw Normal View History

2023-12-17 14:55:27 -05:00
function memusage (bot, options){
const clamp = require('../util/clamp')
const title = 'Memusage'
const os = require('os')
let enabled = false
let tag = 'FNFBoyfriendBotMemusage'
bot.memusage = {
on () {
enabled = true
},
off () {
enabled = false
bot.core.run(`minecraft:title @a actionbar ${title}`)
}
}
const tickRates = []
let nextIndex = 0
let timeLastTimeUpdate = -1
let timeGameJoined
const interval = setInterval(() => {
if (!enabled) return
const component = {
text: `Mem used ${Math.floor(process.memoryUsage().heapUsed / 1000 / 1000)} MiB / ${Math.floor(process.memoryUsage().heapTotal / 1000 / 1000)} MiB. CPU Usage ${JSON.stringify(process.cpuUsage())} `,
color: 'dark_gray'
}//process.cpuUsage
bot.core.run(`minecraft:title @a[tag=${tag}] actionbar ${JSON.stringify(component)}`)
}, 50)//process.memoryUsage().heapUsed /1024 / 1024
}
module.exports = memusage