summary refs log tree commit diff
path: root/scripts/benchmark
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--scripts/benchmark.js26
-rw-r--r--scripts/benchmark/connections.js (renamed from bundle/scripts/benchmark/connections.js)8
-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)4
4 files changed, 32 insertions, 6 deletions
diff --git a/scripts/benchmark.js b/scripts/benchmark.js
new file mode 100644

index 00000000..53db92c5 --- /dev/null +++ b/scripts/benchmark.js
@@ -0,0 +1,26 @@ +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..f74d0c6d 100644 --- a/bundle/scripts/benchmark/connections.js +++ b/scripts/benchmark/connections.js
@@ -4,11 +4,11 @@ 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 { - console.log("[Bundle] Failed to get thread count! Using 1...") + console.log("[Bundle] Failed to get thread count! Using 1..."); } if (!token) { @@ -46,8 +46,8 @@ function connect() { op: 2, d: { token, - properties: {}, - }, + properties: {} + } }) ); 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..415d6d8b 100644 --- a/bundle/scripts/benchmark/users.js +++ b/scripts/benchmark/users.js
@@ -14,9 +14,9 @@ async function main() { consent: true, date_of_birth: "2000-01-01", gift_code_sku_id: null, - captcha_key: null, + captcha_key: null }), - headers: { "content-type": "application/json" }, + headers: { "content-type": "application/json" } }); console.log(i); }