(client)
| 199 | const writeWorkloadSampleSize = argv.writeWorkloadSampleSize || 100; |
| 200 | const writeWorkloadInterval = argv.writeWorkloadInterval || 100; |
| 201 | async function scheduleWriteWorkload(client) { |
| 202 | if (!workloadInterrupt) { |
| 203 | // immediately reschedule work |
| 204 | writeWorkloadTimer = setTimeout(() => scheduleWriteWorkload(client), writeWorkloadInterval); |
| 205 | } |
| 206 | |
| 207 | const currentWriteWorkload = writeWorkloadCounter++; |
| 208 | |
| 209 | try { |
| 210 | const start = processTimeMS(); |
| 211 | await client.db('test').collection('test').insertOne({ a: 42 }); |
| 212 | averageWriteMS = 0.2 * calculateDurationInMs(start) + 0.8 * averageWriteMS; |
| 213 | |
| 214 | completedWriteWorkloads++; |
| 215 | if (completedWriteWorkloads % writeWorkloadSampleSize === 0) { |
| 216 | print( |
| 217 | `${chalk.yellow( |
| 218 | `workload#${currentWriteWorkload}` |
| 219 | )} completed ${completedWriteWorkloads} writes with average time: ${averageWriteMS}` |
| 220 | ); |
| 221 | } |
| 222 | } catch (e) { |
| 223 | print(`${chalk.yellow(`workload#${currentWriteWorkload}`)} write failed: ${e.message}`); |
| 224 | } |
| 225 | } |
| 226 | |
| 227 | let exitRequestCount = 0; |
| 228 | process.on('SIGINT', async function () { |
no test coverage detected