From 9f8aa22b3391dc307cbe17255be3f3b457177886 Mon Sep 17 00:00:00 2001 From: Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> Date: Tue, 9 Aug 2022 23:45:27 +0200 Subject: [PATCH] wip(util): benchmark --- util/.gitignore | 2 ++ util/scripts/benchmark.js | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 util/scripts/benchmark.js diff --git a/util/.gitignore b/util/.gitignore index 87263762..768a0425 100644 --- a/util/.gitignore +++ b/util/.gitignore @@ -15,6 +15,8 @@ pids *.seed *.pid.lock +yarn.lock + # Directory for instrumented libs generated by jscoverage/JSCover lib-cov diff --git a/util/scripts/benchmark.js b/util/scripts/benchmark.js new file mode 100644 index 00000000..f4f34e9e --- /dev/null +++ b/util/scripts/benchmark.js @@ -0,0 +1,22 @@ +const typeorm = require("typeorm"); +const Database = require("../dist/util/Database"); +const Models = require("../dist/entities"); + +function shouldIncludeEntity(name) { + return ![BaseClassWithoutId, PrimaryColumn, BaseClass, PrimaryGeneratedColumn].map((x) => x.name).includes(name); +} + +async function main() { + const db = new typeorm.DataSource({ + driver: "sqlite", + database: ":memory:", + entities: Object.values(Models).filter((x) => x.constructor.name == "Function" && shouldIncludeEntity(x.name)), + }); + await db.initialize(); + + for (var i = 0; i < 100; i++) { + await Models.User.register({ username: "User" + i }); + console.log("registered user " + i); + } +} +main();