diff options
-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(); |