summary refs log tree commit diff
path: root/util/scripts
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2022-08-09 23:45:27 +0200
committerTheArcaneBrony <myrainbowdash949@gmail.com>2022-08-09 23:52:23 +0200
commit9f8aa22b3391dc307cbe17255be3f3b457177886 (patch)
tree09b6363d7329bb638badf6b70a5bcbb47d299114 /util/scripts
parentfix(util): util imports (diff)
downloadserver-9f8aa22b3391dc307cbe17255be3f3b457177886.tar.xz
wip(util): benchmark
Diffstat (limited to 'util/scripts')
-rw-r--r--util/scripts/benchmark.js22
1 files changed, 22 insertions, 0 deletions
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();