Files
puter/tests/api-tester/benches/write_intensive_1.js
T
KernelDeimos 47f7c1146e tweak(apitest): reduce benchmark size
We want this to be fast enough that this benchmark doesn't take a long
time, but part of the effort of making it faster will be running the
benchmark repeatedly, and if it takes a long time then it will take
longer for us to make it faster.

This commit reduces the benchmark size for stat_intensive and
write_intensive so that they don't take several minutes to complete.
2025-11-09 00:37:23 -05:00

32 lines
1.1 KiB
JavaScript

const chai = require('chai');
chai.use(require('chai-as-promised'));
const expect = chai.expect;
module.exports = {
name: 'write intensive 1',
description: 'create 100 new directories and write 10 files in each, then check integrity by stat/readdir/read api',
do: async t => {
console.log('write intensive 1');
const dir_count = 10;
const file_count = 10;
for ( let i = 0 ; i < dir_count ; i++ ) {
await t.mkdir(`dir_${i}`);
for ( let j = 0 ; j < file_count ; j++ ) {
const content = `example ${i} ${j}`;
await t.write(`dir_${i}/file_${j}.txt`, content, { overwrite: true });
}
}
for ( let i = 0 ; i < dir_count ; i++ ) {
const dir = await t.stat(`dir_${i}`);
const files = await t.readdir(dir.path);
expect(files.length).equal(file_count);
for ( let j = 0 ; j < file_count ; j++ ) {
const content = await t.read(`dir_${i}/file_${j}.txt`);
expect(content).equal(`example ${i} ${j}`);
}
}
},
};