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:
parent
6765bfafa7
commit
9f8aa22b33
2
util/.gitignore
vendored
2
util/.gitignore
vendored
@ -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
22
util/scripts/benchmark.js
Normal 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();
|
Loading…
Reference in New Issue
Block a user