If you want to measure the execution time of JavaScript code with callbacks? Use the Node.js console.time()
and console.timeEnd()
:
1 2 3 4 5 6 7 8 9 10 11 | var i; console.time("dbsave"); for(i = 1; i < LIMIT; i++){ db.users.save({id : i, name : "MongoUser [" + i + "]"}, end); } end = function(err, saved) { console.log(( err || !saved )?"Error":"Saved"); if(--i === 1){console.timeEnd("dbsave");} }; |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.