如何改进此代码,因为每当我运行 siege 命令时
siege -d0 -c 100 http://localhost/destinations/list,cpu使用率高达100%?
有什么我可能做错了吗?
/**
* GET /destinations
*/
exports.list = function (req, res, next) {
var query = {
status : 'active'
};
Destination.find(query).populate('landmark', 'name area urlName').populate('city', 'name urlName').populate('image').exec(function(err, destinations) {
if (err)
{
console.log(err + '\n' + __filename + ' ' + __functionName + ' ' + __lineNumber);
res.json({status : 'failed', data : {}, reason : 'Destination not found'});
return;
}
Destination.populate(destinations, {path : 'landmark.area', model : 'Area', select : 'city'}, function(err, destinations) {
Destination.populate(destinations, {path : 'landmark.area.city', model : 'City', select : 'urlName'}, function(err, destinations) {
res.json({status : 'success', data : destinations});
});
});
});
};