mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-02 17:00:08 +00:00
* fix(bench): try to fix benchmark * style: deno fmt * fix: remove check formating * fix: add fake token * fix: tranform * deno fmt * add parseFloat * fix unit * refactor: change fetch target to benchrepo * fix: oldBot * refactor: use custom input * ci: add tee * style: deno fmt * ci: cache deps * chore: remove * ci: add memory benchmark * fix: fix url for main repo * deno fmt * ci: add comment-always * fix: link * just trying trigger * ci: only push on main * fix: type * fix: range * fixed * style: deno fmt * fix: path * Add upload output * style: deno fmt * ci: add create branch on pr owner's repo * fix: github.repository * ci: fix remove id benchmark-action * fix * fix: type * reverse change * ci: add cache * feat: add using cache * bench: update name and ignore previous when ci * style: name * feat: fix pr message style * add more benchmark * deno fmt * fix * fix: wording * chore: only run on success * fix: used last head as current commit
98 lines
3.2 KiB
TypeScript
98 lines
3.2 KiB
TypeScript
import { loadBot as oldLoadBot } from "https://raw.githubusercontent.com/discordeno/discordeno/main/tests/mod.ts";
|
|
import { loadBot } from "../tests/mod.ts";
|
|
|
|
Deno.env.set("DISCORD_TOKEN", `${btoa("316179474163171338")}.gbaodiwabn`);
|
|
const bot = loadBot();
|
|
const oldBot = oldLoadBot();
|
|
|
|
// Fetch the cached guild
|
|
const discordGuild = JSON.parse(
|
|
await (await fetch("https://raw.githubusercontent.com/discordeno/discordeno/benchies/cache/cachedObject/guild.json"))
|
|
.text(),
|
|
);
|
|
|
|
const currentGuild = bot.transformers.guild(bot, { guild: discordGuild, shardId: 0 });
|
|
const previousGuild = oldBot.transformers.guild(oldBot, { guild: discordGuild, shardId: 0 });
|
|
|
|
Deno.bench("[Guild.toggles.features] Get the features of a guild", () => {
|
|
currentGuild.toggles.features;
|
|
});
|
|
|
|
Deno.bench("[Guild.toggles.features - Previous] Get the features of a guild", {
|
|
ignore: Deno.env.get("CI") === "true",
|
|
}, () => {
|
|
previousGuild.toggles.features;
|
|
});
|
|
|
|
// Fetch the cached user
|
|
const discordUser = JSON.parse(
|
|
await (await fetch("https://raw.githubusercontent.com/discordeno/discordeno/benchies/cache/cachedObject/user.json"))
|
|
.text(),
|
|
);
|
|
|
|
const newUser = bot.transformers.user(bot, discordUser);
|
|
const oldUser = oldBot.transformers.user(oldBot, discordUser);
|
|
|
|
Deno.bench("[Transformer] Discord User to a User", () => {
|
|
bot.transformers.user(bot, discordUser);
|
|
});
|
|
|
|
Deno.bench("[Transformer - Previous] Discord User to a User", {
|
|
ignore: Deno.env.get("CI") === "true",
|
|
}, () => {
|
|
oldBot.transformers.user(oldBot, discordUser);
|
|
});
|
|
|
|
Deno.bench("[Transformer] User to a Discord User", () => {
|
|
bot.transformers.reverse.user(bot, newUser);
|
|
});
|
|
|
|
Deno.bench("[Transformer - Previous] User to a Discord User", {
|
|
ignore: Deno.env.get("CI") === "true",
|
|
}, () => {
|
|
oldBot.transformers.reverse.user(oldBot, oldUser);
|
|
});
|
|
|
|
for (
|
|
const channelType of [
|
|
"rules",
|
|
"announcement-channel",
|
|
"moderator-channel",
|
|
"text-channel",
|
|
"stage-channel",
|
|
"voice-channel",
|
|
]
|
|
) {
|
|
const discordChannel = JSON.parse(
|
|
await (await fetch(
|
|
`https://raw.githubusercontent.com/discordeno/discordeno/benchies/cache/cachedObject/${channelType}.json`,
|
|
)).text(),
|
|
);
|
|
const formattedChannelType = channelType.split("-").map((word) => word[0].toUpperCase() + word.slice(1)).join(" ");
|
|
|
|
Deno.bench(`[Transformer] Discord ${formattedChannelType} to a ${formattedChannelType}`, () => {
|
|
bot.transformers.channel(bot, { channel: discordChannel });
|
|
});
|
|
|
|
Deno.bench(`[Transformer - Previous] Discord ${formattedChannelType} to a ${formattedChannelType}`, {
|
|
ignore: Deno.env.get("CI") === "true",
|
|
}, () => {
|
|
oldBot.transformers.channel(oldBot, { channel: discordChannel });
|
|
});
|
|
|
|
/* Not implemented
|
|
const newChannel = bot.transformers.channel(bot, { channel: discordChannel });
|
|
const oldChannel = oldBot.transformers.channel(oldBot, { channel: discordChannel });
|
|
|
|
Deno.bench(`[Transformer] ${formattedChannelType} to a Discord ${formattedChannelType}`, () => {
|
|
bot.transformers.reverse.channel(bot, newChannel);
|
|
});
|
|
|
|
Deno.bench(`[Transformer - Previous] ${formattedChannelType} to a Discord ${formattedChannelType}`, {
|
|
ignore: Deno.env.get("CI") === "true",
|
|
}, () => {
|
|
oldBot.transformers.reverse.channel(oldBot, oldChannel);
|
|
});
|
|
*/
|
|
}
|