1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-14 22:52:41 +01:00

wip(util): benchmark

This commit is contained in:
Flam3rboy 2022-08-09 23:45:27 +02:00 committed by TheArcaneBrony
parent 6765bfafa7
commit 9f8aa22b33
No known key found for this signature in database
GPG Key ID: 32FC5AAADAD75A22
2 changed files with 24 additions and 0 deletions

2
util/.gitignore vendored
View File

@ -15,6 +15,8 @@ pids
*.seed
*.pid.lock
yarn.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

22
util/scripts/benchmark.js Normal file
View File

@ -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();