From 08e837bf5559e9680fc8cb99bd05b93f8eb2cac5 Mon Sep 17 00:00:00 2001 From: Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> Date: Thu, 12 Aug 2021 20:09:35 +0200 Subject: :sparkles: api --- api/src/test/server_benchmark.ts | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 api/src/test/server_benchmark.ts (limited to 'api/src/test/server_benchmark.ts') diff --git a/api/src/test/server_benchmark.ts b/api/src/test/server_benchmark.ts new file mode 100644 index 00000000..c582ee89 --- /dev/null +++ b/api/src/test/server_benchmark.ts @@ -0,0 +1,39 @@ +// @ts-nocheck +import "missing-native-js-functions"; +import { config } from "dotenv"; +config(); +import { DiscordServer } from "../Server"; +import fetch from "node-fetch"; +import { promises } from "fs"; +const count = 100; + +async function main() { + const server = new DiscordServer({ port: 3000 }); + await server.start(); + + const tasks = []; + for (let i = 0; i < count; i++) { + tasks.push(test()); + } + + await Promise.all(tasks); + + console.log("logging in 5secs"); + setTimeout(async () => { + await test(); + + process.exit(); + }, 5000); +} +main(); + +async function test() { + const res = await fetch("http://localhost:3000/api/v8/guilds/813524615463698433/members/813524464300982272", { + headers: { + authorization: + "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjgxMzUyNDQ2NDMwMDk4MjI3MiIsImlhdCI6MTYxNDAyOTc0Nn0.6WQiU4D5HHRi3sliHOQe1hsW-hZTEttvdtZuNIdviNI", + }, + }); + + return await res.text(); +} -- cgit 1.5.1