diff options
author | Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> | 2022-08-09 23:45:27 +0200 |
---|---|---|
committer | TheArcaneBrony <myrainbowdash949@gmail.com> | 2022-08-09 23:52:23 +0200 |
commit | 9f8aa22b3391dc307cbe17255be3f3b457177886 (patch) | |
tree | 09b6363d7329bb638badf6b70a5bcbb47d299114 /util | |
parent | fix(util): util imports (diff) | |
download | server-9f8aa22b3391dc307cbe17255be3f3b457177886.tar.xz |
wip(util): benchmark
Diffstat (limited to 'util')
-rw-r--r-- | util/.gitignore | 2 | ||||
-rw-r--r-- | util/scripts/benchmark.js | 22 |
2 files changed, 24 insertions, 0 deletions
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(); |