()
| 31 | }; |
| 32 | |
| 33 | async function main() { |
| 34 | log('starting execution'); |
| 35 | const startingMemoryUsed = process.memoryUsage().heapUsed / MB; |
| 36 | process.send({ startingMemoryUsed }); |
| 37 | |
| 38 | log('sent first message'); |
| 39 | |
| 40 | for (let iteration = 0; iteration < iterations; iteration++) { |
| 41 | await run({ MongoClient, uri, iteration }); |
| 42 | iteration % 20 === 0 && log(`iteration ${iteration} complete`); |
| 43 | global.gc(); |
| 44 | } |
| 45 | |
| 46 | log('script executed'); |
| 47 | |
| 48 | global.gc(); |
| 49 | // Sleep b/c maybe gc will run |
| 50 | await sleep(100); |
| 51 | global.gc(); |
| 52 | |
| 53 | const endingMemoryUsed = process.memoryUsage().heapUsed / MB; |
| 54 | |
| 55 | log('sending second message'); |
| 56 | |
| 57 | process.send({ endingMemoryUsed }); |
| 58 | log('second message sent.'); |
| 59 | |
| 60 | const clientsInMemory = v8.queryObjects(MongoClient); |
| 61 | |
| 62 | process.send({ clientsInMemory }); |
| 63 | |
| 64 | log('clients instances in memory sent.'); |
| 65 | } |
| 66 | |
| 67 | main() |
| 68 | .then(() => { |
no test coverage detected