From d34daabc4eec9900b11bc04d50afc0b61016d061 Mon Sep 17 00:00:00 2001 From: WubzyGD Date: Fri, 14 Jan 2022 23:05:42 -0700 Subject: [PATCH] log cache time --- bot.js | 1 - util/cache/anime.js | 4 ++++ util/cache/ar.js | 4 ++++ util/cache/bl.js | 8 ++++++++ util/cache/char.js | 4 ++++ util/cache/chest.js | 4 ++++ util/cache/lr.js | 4 ++++ util/cache/lxp.js | 4 ++++ util/cache/monit.js | 4 ++++ 9 files changed, 36 insertions(+), 1 deletion(-) diff --git a/bot.js b/bot.js index 766ff39..8555a8c 100644 --- a/bot.js +++ b/bot.js @@ -150,7 +150,6 @@ async function init() { } for (let i = 0; i < iters.length; i++) {let x = iters[i]; await require(`./handle/${x}`)(client);} if (client.misc.config.spinners) { - await require('./util/wait')(1000); client.misc.cache.spinLog.forEach(log => console.log(log)); } if (!client.misc.config.nocli) {require('./handle/console')(client);} diff --git a/util/cache/anime.js b/util/cache/anime.js index 5d089e5..2efcea7 100644 --- a/util/cache/anime.js +++ b/util/cache/anime.js @@ -5,6 +5,8 @@ const AniData = require('../../models/anime'); module.exports = async (client, spinner) => { return new Promise(async resolve => { + const st = new Date().getTime(); + client.misc.cache.anime = new Discord.Collection(); client.misc.cache.animeID = new Discord.Collection(); client.misc.cache.animeLove = new Discord.Collection(); @@ -24,6 +26,8 @@ module.exports = async (client, spinner) => { } } + const cacheTime = new Date().getTime() - st; + spinner.update({text: `${spinner.options.text.slice(0, 19).trim()} ${chalk.gray(`${cacheTime}ms >>`.padStart(8, '0').padStart(7, '0'))} ${spinner.options.text.slice(19).trim()}`}); spinner.status('non-spinnable'); resolve(0); diff --git a/util/cache/ar.js b/util/cache/ar.js index d4a4665..146338e 100644 --- a/util/cache/ar.js +++ b/util/cache/ar.js @@ -3,6 +3,8 @@ const chalk = require('chalk'); module.exports = async (client, spinner) => { return new Promise(async resolve => { + const st = new Date().getTime(); + client.misc.cache.ar = new Map(); client.misc.cache.arIgnore = new Map(); let amount = 0; @@ -14,6 +16,8 @@ module.exports = async (client, spinner) => { amount++; } + const cacheTime = new Date().getTime() - st; + spinner.update({text: `${spinner.options.text.slice(0, 19).trim()} ${chalk.gray(`${cacheTime}ms >>`.padStart(8, '0').padStart(7, '0'))} ${spinner.options.text.slice(19).trim()}`}); spinner.status('non-spinnable'); resolve(0); }); diff --git a/util/cache/bl.js b/util/cache/bl.js index c49ba69..3530522 100644 --- a/util/cache/bl.js +++ b/util/cache/bl.js @@ -4,6 +4,8 @@ const chalk = require('chalk'); module.exports = async (client, spinner, spinner2) => { return new Promise(async resolve => { + const st = new Date().getTime(); + client.misc.cache.bl = { guild: [], user: [] @@ -17,14 +19,20 @@ module.exports = async (client, spinner, spinner2) => { } spinner.update({text: `${chalk.gray('[PROC]')} >> ${chalk.blueBright(`Cached`)} ${chalk.white(`${amount}`)} ${chalk.blueBright(`guild blacklists.`)}`}); + const cacheTime = new Date().getTime() - st; + spinner.update({text: `${spinner.options.text.slice(0, 19).trim()} ${chalk.gray(`${cacheTime}ms >>`.padStart(8, '0').padStart(7, '0'))} ${spinner.options.text.slice(19).trim()}`}); spinner.status('non-spinnable'); + const st2 = new Date().getTime(); + for await (const user of UserData.find()) { if (user.blackisted) {client.misc.cache.bl.user.push(user.uid); amount2++;} spinner2.update({text: `${chalk.gray('[PROC]')} >> ${chalk.blueBright(`Cached`)} ${chalk.white(`${amount2}`)} ${chalk.blueBright(`user blacklists.`)}`}); } spinner2.update({text: `${chalk.gray('[PROC]')} >> ${chalk.blueBright(`Cached`)} ${chalk.white(`${amount2}`)} ${chalk.blueBright(`user blacklists.`)}`}); + const cacheTime2 = new Date().getTime() - st2; + spinner2.update({text: `${spinner2.options.text.slice(0, 19).trim()} ${chalk.gray(`${cacheTime2}ms >>`.padStart(8, '0').padStart(7, '0'))} ${spinner2.options.text.slice(19).trim()}`}); spinner2.status('non-spinnable'); resolve(0); diff --git a/util/cache/char.js b/util/cache/char.js index 4059362..367030d 100644 --- a/util/cache/char.js +++ b/util/cache/char.js @@ -5,6 +5,8 @@ const CharData = require('../../models/char'); module.exports = async (client, spinner) => { return new Promise(async resolve => { + const st = new Date().getTime(); + client.misc.cache.chars = new Discord.Collection(); client.misc.cache.charsID = new Discord.Collection(); client.misc.cache.charsLove = new Discord.Collection(); @@ -23,6 +25,8 @@ module.exports = async (client, spinner) => { } } + const cacheTime = new Date().getTime() - st; + spinner.update({text: `${spinner.options.text.slice(0, 19).trim()} ${chalk.gray(`${cacheTime}ms >>`.padStart(8, '0').padStart(7, '0'))} ${spinner.options.text.slice(19).trim()}`}); spinner.status('non-spinnable'); resolve(0); diff --git a/util/cache/chest.js b/util/cache/chest.js index 8b668f3..e8037ff 100644 --- a/util/cache/chest.js +++ b/util/cache/chest.js @@ -3,6 +3,8 @@ const chalk = require('chalk'); module.exports = async (client, spinner) => { return new Promise(async resolve => { + const st = new Date().getTime(); + client.misc.cache.chests.enabled = []; let amount = 0; @@ -12,6 +14,8 @@ module.exports = async (client, spinner) => { amount++; } + const cacheTime = new Date().getTime() - st; + spinner.update({text: `${spinner.options.text.slice(0, 19).trim()} ${chalk.gray(`${cacheTime}ms >>`.padStart(8, '0').padStart(7, '0'))} ${spinner.options.text.slice(19).trim()}`}); spinner.status('non-spinnable'); resolve(0); }); diff --git a/util/cache/lr.js b/util/cache/lr.js index c99fa21..b815cd7 100644 --- a/util/cache/lr.js +++ b/util/cache/lr.js @@ -3,6 +3,8 @@ const chalk = require('chalk'); module.exports = async (client, spinner) => { return new Promise(async resolve => { + const st = new Date().getTime(); + client.misc.cache.lxp.hasLevelRoles = []; let amount = 0; @@ -12,6 +14,8 @@ module.exports = async (client, spinner) => { amount++; } + const cacheTime = new Date().getTime() - st; + spinner.update({text: `${spinner.options.text.slice(0, 19).trim()} ${chalk.gray(`${cacheTime}ms >>`.padStart(8, '0').padStart(7, '0'))} ${spinner.options.text.slice(19).trim()}`}); spinner.status('non-spinnable'); resolve(0); diff --git a/util/cache/lxp.js b/util/cache/lxp.js index 16a99d7..6a0dcec 100644 --- a/util/cache/lxp.js +++ b/util/cache/lxp.js @@ -3,6 +3,8 @@ const chalk = require('chalk'); module.exports = async (client, spinner) => { return new Promise(async resolve => { + const st = new Date().getTime(); + client.misc.cache.lxp.enabled = []; client.misc.cache.lxp.disabledChannels = new Map(); client.misc.cache.chests.enabled = new Map(); @@ -15,6 +17,8 @@ module.exports = async (client, spinner) => { amount++; } + const cacheTime = new Date().getTime() - st; + spinner.update({text: `${spinner.options.text.slice(0, 19).trim()} ${chalk.gray(`${cacheTime}ms >>`.padStart(8, '0').padStart(7, '0'))} ${spinner.options.text.slice(19).trim()}`}); spinner.status('non-spinnable'); resolve(0); }); diff --git a/util/cache/monit.js b/util/cache/monit.js index 877f28a..bf4fc23 100644 --- a/util/cache/monit.js +++ b/util/cache/monit.js @@ -3,6 +3,8 @@ const chalk = require('chalk'); module.exports = async (client, spinner) => { return new Promise(async resolve => { + const st = new Date().getTime(); + client.misc.cache.monit = {}; client.misc.cache.monitEnabled = []; let amount = 0; @@ -18,6 +20,8 @@ module.exports = async (client, spinner) => { amount++; } + const cacheTime = new Date().getTime() - st; + spinner.update({text: `${spinner.options.text.slice(0, 19).trim()} ${chalk.gray(`${cacheTime}ms >>`.padStart(8, '0').padStart(7, '0'))} ${spinner.options.text.slice(19).trim()}`}); spinner.status('non-spinnable'); resolve(0);