From 98228c8dc125772e1cf1e01f68fdb966cdbf2e40 Mon Sep 17 00:00:00 2001 From: "S. Amir Mohammad Najafi" Date: Wed, 27 Dec 2023 18:52:00 +0330 Subject: [PATCH] chore(engine): demo --- packages/engine/demo/benchmark.mjs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 packages/engine/demo/benchmark.mjs diff --git a/packages/engine/demo/benchmark.mjs b/packages/engine/demo/benchmark.mjs new file mode 100644 index 00000000..0e5f6c8c --- /dev/null +++ b/packages/engine/demo/benchmark.mjs @@ -0,0 +1,29 @@ +import {random} from '@alwatr/math'; +import {AlwatrStorageEngine} from '../dist/main'; + +const db = new AlwatrStorageEngine({ + name: 'junk-data', + path: 'db', + saveBeautiful: false, + devMode: false, +}); + +console.time('set all items'); + +const max = 100_000; +for (let i = 0; i < max; i++) { + db.set({ + id: 'user_' + i, + fname: random.string(4, 16), + lname: random.string(4, 32), + email: random.string(8, 32), + token: random.string(16), + }); +} + +console.timeEnd('set all items'); + +console.time('get item'); +const item = db.get('user_' + max / 2); +console.timeEnd('get item'); +console.dir(item);