@@ -39,8 +39,17 @@ function main({ encodingType, duration, concurrent, size }) {
|
39 | 39 | let writes = 0; |
40 | 40 | let waitConcurrent = 0; |
41 | 41 | |
42 | | -const startedAt = Date.now(); |
43 | | -const endAt = startedAt + (duration * 1000); |
| 42 | +let startedAt = Date.now(); |
| 43 | +let endAt = startedAt + duration * 1000; |
| 44 | + |
| 45 | +// fs warmup |
| 46 | +for (let i = 0; i < concurrent; i++) write(); |
| 47 | + |
| 48 | +writes = 0; |
| 49 | +waitConcurrent = 0; |
| 50 | + |
| 51 | +startedAt = Date.now(); |
| 52 | +endAt = startedAt + duration * 1000; |
44 | 53 | |
45 | 54 | bench.start(); |
46 | 55 | |
@@ -59,7 +68,8 @@ function main({ encodingType, duration, concurrent, size }) {
|
59 | 68 | } |
60 | 69 | |
61 | 70 | function write() { |
62 | | -fs.promises.writeFile(`${filename}-${filesWritten++}`, chunk, encoding) |
| 71 | +fs.promises |
| 72 | +.writeFile(`${filename}-${filesWritten++}`, chunk, encoding) |
63 | 73 | .then(() => afterWrite()) |
64 | 74 | .catch((err) => afterWrite(err)); |
65 | 75 | } |
@@ -72,7 +82,7 @@ function main({ encodingType, duration, concurrent, size }) {
|
72 | 82 | writes++; |
73 | 83 | const benchEnded = Date.now() >= endAt; |
74 | 84 | |
75 | | -if (benchEnded && (++waitConcurrent) === concurrent) { |
| 85 | +if (benchEnded && ++waitConcurrent === concurrent) { |
76 | 86 | stop(); |
77 | 87 | } else if (!benchEnded) { |
78 | 88 | write(); |
|