Skip to content

Commit 47f7c11

Browse files
committed
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.
1 parent 7d78381 commit 47f7c11

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const chai = require('chai');
2-
chai.use(require('chai-as-promised'))
2+
chai.use(require('chai-as-promised'));
33
const expect = chai.expect;
44

55
module.exports = {
@@ -9,29 +9,29 @@ module.exports = {
99
console.log('stat intensive 1');
1010

1111
const dir_count = 10;
12-
const subdir_count = 100;
12+
const subdir_count = 10;
1313

1414
// key: uuid
1515
// value: path
1616
const dirs = {};
1717

18-
for (let i = 0; i < dir_count; i++) {
18+
for ( let i = 0; i < dir_count; i++ ) {
1919
await t.mkdir(`dir_${i}`);
20-
for (let j = 0; j < subdir_count; j++) {
20+
for ( let j = 0; j < subdir_count; j++ ) {
2121
const subdir = await t.mkdir(`dir_${i}/subdir_${j}`);
2222
dirs[subdir.uid] = subdir.path;
2323
}
2424
}
2525

2626
const start = Date.now();
27-
for (let i = 0; i < 10; i++) {
28-
for (const [uuid, path] of Object.entries(dirs)) {
27+
for ( let i = 0; i < 10; i++ ) {
28+
for ( const [uuid, path] of Object.entries(dirs) ) {
2929
const stat = await t.stat_uuid(uuid);
3030
expect(stat.is_dir).equal(true);
3131
expect(stat.path).equal(path);
3232
}
3333
}
3434
const duration = Date.now() - start;
3535
return { duration };
36-
}
36+
},
3737
};
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const chai = require('chai');
2-
chai.use(require('chai-as-promised'))
2+
chai.use(require('chai-as-promised'));
33
const expect = chai.expect;
44

55
module.exports = {
@@ -8,25 +8,25 @@ module.exports = {
88
do: async t => {
99
console.log('write intensive 1');
1010

11-
const dir_count = 100;
11+
const dir_count = 10;
1212
const file_count = 10;
1313

14-
for ( let i=0 ; i < dir_count ; i++ ) {
14+
for ( let i = 0 ; i < dir_count ; i++ ) {
1515
await t.mkdir(`dir_${i}`);
16-
for ( let j=0 ; j < file_count ; j++ ) {
16+
for ( let j = 0 ; j < file_count ; j++ ) {
1717
const content = `example ${i} ${j}`;
1818
await t.write(`dir_${i}/file_${j}.txt`, content, { overwrite: true });
1919
}
2020
}
2121

22-
for ( let i=0 ; i < dir_count ; i++ ) {
22+
for ( let i = 0 ; i < dir_count ; i++ ) {
2323
const dir = await t.stat(`dir_${i}`);
2424
const files = await t.readdir(dir.path);
2525
expect(files.length).equal(file_count);
26-
for ( let j=0 ; j < file_count ; j++ ) {
26+
for ( let j = 0 ; j < file_count ; j++ ) {
2727
const content = await t.read(`dir_${i}/file_${j}.txt`);
2828
expect(content).equal(`example ${i} ${j}`);
2929
}
3030
}
31-
}
31+
},
3232
};

0 commit comments

Comments
 (0)