I have a piece of javascript code that I am executing using the node.js interpreter.(我有一段javascript代码,我正在使用node.js解释器执行。)
for(var i = 1; i < LIMIT; i++){
db.users.save({id : i, name : "MongoUser [" + i + "]"}, function(err, saved) {
if( err || !saved ) console.log("Error");
else console.log("Saved");
});
}
I want to know how to measure the time taken by these db insert operations.(我想知道如何测量这些数据库插入操作所花费的时间。) I could compute the difference of Date values after and before this piece of code but that would be incorrect because of the asynchronous nature of the code.(我可以计算这段代码之前和之前的Date值的差异,但由于代码的异步性质,这将是不正确的。)
ask by Stormshadow translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…