Commit babeb4cf authored by 陈志良's avatar 陈志良

增加耗时Log

parent 88744e39
...@@ -581,7 +581,7 @@ router.get('/thread/:tid/get', function(req, res, next) { ...@@ -581,7 +581,7 @@ router.get('/thread/:tid/get', function(req, res, next) {
threads.push(thread); threads.push(thread);
var firstLoadLevelBegin = new Date(); var firstLoadLevelBegin = new Date();
util.loadLevel(req.session.user.ent_code, threads, function() { util.loadLevel(req.session.user.ent_code, threads, function() {
console.log("firstLoadLevelTime:"+Math.abs(new Date() - firstLoadLevelBegin)); console.log("获取帖子相关用户的经验(一个OpenId拿一次)总耗时:"+Math.abs(new Date() - firstLoadLevelBegin));
if (threads && threads.length > 0) { if (threads && threads.length > 0) {
thread = threads[0]; thread = threads[0];
} }
......
...@@ -311,6 +311,7 @@ exports.getThreadById = function(tid, callback) { ...@@ -311,6 +311,7 @@ exports.getThreadById = function(tid, callback) {
if (doc) { if (doc) {
async.parallel([ async.parallel([
function(cb) { function(cb) {
var getAllCommentBegin = new Date();
if (doc.type !== 1) { if (doc.type !== 1) {
cb(null, null); cb(null, null);
return; return;
...@@ -321,6 +322,7 @@ exports.getThreadById = function(tid, callback) { ...@@ -321,6 +322,7 @@ exports.getThreadById = function(tid, callback) {
}; };
//获取最新10条评论 //获取最新10条评论
forumCommentService.getAllComment(conditions, 1, 10, function(err, results) { forumCommentService.getAllComment(conditions, 1, 10, function(err, results) {
console.log("获取最新10条评论耗时:" + Math.abs(new Date()-getAllCommentBegin));
if (err) { if (err) {
console.log(err); console.log(err);
cb(err, null); cb(err, null);
...@@ -404,6 +406,7 @@ exports.getThreadById = function(tid, callback) { ...@@ -404,6 +406,7 @@ exports.getThreadById = function(tid, callback) {
// }); // });
// }, // },
function(cb) { function(cb) {
var canyuPeopleCountBegin = new Date();
//获取发帖人数 //获取发帖人数
var key = 'pisns-forum-thread:' + tid + ':amount'; var key = 'pisns-forum-thread:' + tid + ':amount';
redis.get(key,function(err,value){ redis.get(key,function(err,value){
...@@ -433,6 +436,7 @@ exports.getThreadById = function(tid, callback) { ...@@ -433,6 +436,7 @@ exports.getThreadById = function(tid, callback) {
} }
}); });
} }
console.log("获取发帖人数耗时:" + Math.abs(new Date()-begin));
}); });
// ForumThread.aggregate({ // ForumThread.aggregate({
...@@ -473,7 +477,7 @@ exports.getThreadById = function(tid, callback) { ...@@ -473,7 +477,7 @@ exports.getThreadById = function(tid, callback) {
// threadObj.latestPhotos = latestPhotos; // threadObj.latestPhotos = latestPhotos;
// threadObj.hotPhotos = hotPhotos; // threadObj.hotPhotos = hotPhotos;
threadObj.canyuPeopleCount = canyuPeopleCount; threadObj.canyuPeopleCount = canyuPeopleCount;
console.log("getThreadByIdTime:" + Math.abs(new Date()-end)); console.log("获取帖子内容总耗时:" + Math.abs(new Date()-begin));
callback(null, threadObj); callback(null, threadObj);
} }
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment