How to Measure Total Execution Time of MongoDB Queries
I’ll introduce how to measure the total execution time of MongoDB queries.
To measure execution time of MongoDB find or aggregate queries, there are the following methods:
This article introduces how to measure total execution time of JavaScript code spanning multiple lines, not just measuring a single find() or aggregate().
var before = new Date()
// execute your query
load('/path/to/your_query.js')
var after = new Date()
var executionMilliseconds = after - before
print(executionMilliseconds + ' ms')
print(executionMilliseconds/1000 + ' sec')
That’s all from the Gemba.