added tool for load-testing many items

This commit is contained in:
Sören Oesterwind 2023-07-09 23:37:48 +02:00
parent ff07698f16
commit 45a4935190
2 changed files with 36 additions and 0 deletions

1
.gitignore vendored
View File

@ -4,3 +4,4 @@ node_modules
config.json config.json
dist dist
docs docs
demoData.json

35
tools/generate.js Normal file
View File

@ -0,0 +1,35 @@
/**
* This file can be used to load-test the application
*/
import { writeFileSync } from "fs";
// Temporary file to generate demo data for the inventory
const inventoryItems = [];
// Function to add an item to the inventory using a simple function
function addInventoryItem(name, amount, manufacturer, category, sku) {
const item = {
name: name,
amount: amount,
manufacturer: manufacturer,
category: category,
sku: sku
};
inventoryItems.push(item);
}
// Loop to generate 2000 items
for (let i = 1; i <= 1024; i++) {
const itemName = `Item ${i}`;
const itemAmount = Math.floor(Math.random() * 100) + 1;
const itemManufacturer = `Manufacturer ${i}`;
const itemCategory = `Category ${i}`;
const itemSKU = `SKU-${i}`;
addInventoryItem(itemName, itemAmount, itemManufacturer, itemCategory, itemSKU);
}
// Save the generated data to a file
writeFileSync('demoData.json', JSON.stringify(inventoryItems))