added tool for load-testing many items
This commit is contained in:
parent
ff07698f16
commit
45a4935190
1
.gitignore
vendored
1
.gitignore
vendored
@ -4,3 +4,4 @@ node_modules
|
||||
config.json
|
||||
dist
|
||||
docs
|
||||
demoData.json
|
35
tools/generate.js
Normal file
35
tools/generate.js
Normal 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))
|
Loading…
Reference in New Issue
Block a user