MCPcopy
hub / github.com/mongodb/node-mongodb-native / scheduleWriteWorkload

Function scheduleWriteWorkload

etc/sdam_viz.js:201–225  ·  view source on GitHub ↗
(client)

Source from the content-addressed store, hash-verified

199const writeWorkloadSampleSize = argv.writeWorkloadSampleSize || 100;
200const writeWorkloadInterval = argv.writeWorkloadInterval || 100;
201async 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
227let exitRequestCount = 0;
228process.on('SIGINT', async function () {

Callers 1

runFunction · 0.85

Calls 6

processTimeMSFunction · 0.85
calculateDurationInMsFunction · 0.85
insertOneMethod · 0.80
printFunction · 0.70
collectionMethod · 0.65
dbMethod · 0.45

Tested by

no test coverage detected