summary refs log tree commit diff
path: root/scripts/benchmark
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--scripts/benchmark.js28
-rw-r--r--scripts/benchmark/connections.js (renamed from bundle/scripts/benchmark/connections.js)2
-rw-r--r--scripts/benchmark/index.js (renamed from bundle/scripts/benchmark/index.js)0
-rw-r--r--scripts/benchmark/users.js (renamed from bundle/scripts/benchmark/users.js)0
4 files changed, 29 insertions, 1 deletions
diff --git a/scripts/benchmark.js b/scripts/benchmark.js
new file mode 100644

index 00000000..e7435191 --- /dev/null +++ b/scripts/benchmark.js
@@ -0,0 +1,28 @@ +const typeorm = require("typeorm"); +const Models = require("../dist/entities"); +const { PrimaryColumn } = require("typeorm"); + +function shouldIncludeEntity(name) { + return ![Models.BaseClassWithoutId, PrimaryColumn, Models.BaseClass, Models.PrimaryGeneratedColumn] + .map((x) => x?.name) + .includes(name); +} + +async function main() { + console.log("starting"); + const db = new typeorm.DataSource({ + type: "sqlite", + database: ":memory:", + entities: Object.values(Models).filter((x) => x.constructor.name == "Function" && shouldIncludeEntity(x.name)), + synchronize: true, + }); + await db.initialize(); + console.log("Initialized database"); + + for (var i = 0; i < 100; i++) { + await Models.User.register({ username: "User" + i }); + console.log("registered user " + i); + } +} + +main(); diff --git a/bundle/scripts/benchmark/connections.js b/scripts/benchmark/connections.js
index ffca2628..661548c3 100644 --- a/bundle/scripts/benchmark/connections.js +++ b/scripts/benchmark/connections.js
@@ -4,7 +4,7 @@ const WebSocket = require("ws"); const endpoint = process.env.GATEWAY || "ws://localhost:3001"; const connections = Number(process.env.CONNECTIONS) || 50; const token = process.env.TOKEN; -var cores = 1; +let cores = 1; try { cores = Number(process.env.THREADS) || os.cpus().length; } catch { diff --git a/bundle/scripts/benchmark/index.js b/scripts/benchmark/index.js
index 37ac5633..37ac5633 100644 --- a/bundle/scripts/benchmark/index.js +++ b/scripts/benchmark/index.js
diff --git a/bundle/scripts/benchmark/users.js b/scripts/benchmark/users.js
index bce67bf4..bce67bf4 100644 --- a/bundle/scripts/benchmark/users.js +++ b/scripts/benchmark/users.js