From f7196166387c8404b3a64e1c414360d59d4b015c Mon Sep 17 00:00:00 2001 From: Brian Simpson Date: Fri, 14 Feb 2014 02:08:50 -0500 Subject: [PATCH] Add a timer around get_num_children. --- r2/r2/models/builder.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/r2/r2/models/builder.py b/r2/r2/models/builder.py index 9282ca160..cf3fb23a5 100755 --- a/r2/r2/models/builder.py +++ b/r2/r2/models/builder.py @@ -799,19 +799,20 @@ class CommentBuilder(Builder): more_recursions[parent_id] = w timer.intermediate("pick_comments") + + # retrieve num_children for the visible comments + top_level_candidates = [comment for sort_val, comment in candidates + if depth.get(comment, 0) == 0] + needs_num_children = items + top_level_candidates + num_children = get_num_children(needs_num_children, cid_tree) + timer.intermediate("calc_num_children") + comments = Comment._byID(items, data=True, return_dict=False, stale=self.stale) wrapped = self.wrap_items(comments) wrapped_by_id = {comment._id: comment for comment in wrapped} final = [] - # retrieve num_children for the wrapped comments - visible_comments = wrapped_by_id.keys() - top_level_candidates = [comment for sort_val, comment in candidates - if depth.get(comment, 0) == 0] - needs_num_children = visible_comments + top_level_candidates - num_children = get_num_children(needs_num_children, cid_tree) - for comment in wrapped: # skip deleted comments with no children if (comment.deleted and not cid_tree.has_key(comment._id)