diff --git a/webapp_post.py b/webapp_post.py index fba4cafd3..91b642a2d 100644 --- a/webapp_post.py +++ b/webapp_post.py @@ -145,23 +145,13 @@ def getPostFromRecentCache(session, getPersonAvatarUrl(baseDir, postActor, personCache, allowDownloads) - # benchmark 2.1 - if enableTimingLog: - timeDiff = int((time.time() - postStartTime) * 1000) - if timeDiff > 100: - print('TIMING INDIV ' + boxName + - ' 2.1 = ' + str(timeDiff)) + logPostTiming(enableTimingLog, postStartTime, '2.1') updateAvatarImageCache(session, baseDir, httpPrefix, postActor, avatarUrl, personCache, allowDownloads) - # benchmark 2.2 - if enableTimingLog: - timeDiff = int((time.time() - postStartTime) * 1000) - if timeDiff > 100: - print('TIMING INDIV ' + boxName + - ' 2.2 = ' + str(timeDiff)) + logPostTiming(enableTimingLog, postStartTime, '2.2') postHtml = \ loadIndividualPostAsHtmlFromCache(baseDir, nickname, domain, @@ -172,12 +162,7 @@ def getPostFromRecentCache(session, postHtml = preparePostFromHtmlCache(postHtml, boxName, pageNumber) updateRecentPostsCache(recentPostsCache, maxRecentPosts, postJsonObject, postHtml) - # benchmark 3 - if enableTimingLog: - timeDiff = int((time.time() - postStartTime) * 1000) - if timeDiff > 100: - print('TIMING INDIV ' + boxName + - ' 3 = ' + str(timeDiff)) + logPostTiming(enableTimingLog, postStartTime, '3') return postHtml @@ -417,11 +402,7 @@ def getLikeIconHtml(nickname: str, domainFull: str, likeTitle = translate['Like this post'] likeCount = noOfLikes(postJsonObject) - # benchmark 12.1 - if enableTimingLog: - timeDiff = int((time.time() - postStartTime) * 1000) - if timeDiff > 100: - print('TIMING INDIV ' + boxName + ' 12.1 = ' + str(timeDiff)) + logPostTiming(enableTimingLog, postStartTime, '12.1') likeCountStr = '' if likeCount > 0: @@ -437,11 +418,7 @@ def getLikeIconHtml(nickname: str, domainFull: str, likeLink = 'unlike' likeTitle = translate['Undo the like'] - # benchmark 12.2 - if enableTimingLog: - timeDiff = int((time.time() - postStartTime) * 1000) - if timeDiff > 100: - print('TIMING INDIV ' + boxName + ' 12.2 = ' + str(timeDiff)) + logPostTiming(enableTimingLog, postStartTime, '12.2') likeStr = '' if likeCountStr: @@ -488,11 +465,7 @@ def getBookmarkIconHtml(nickname: str, domainFull: str, bookmarkIcon = 'bookmark.png' bookmarkLink = 'unbookmark' bookmarkTitle = translate['Undo the bookmark'] - # benchmark 12.6 - if enableTimingLog: - timeDiff = int((time.time() - postStartTime) * 1000) - if timeDiff > 100: - print('TIMING INDIV ' + boxName + ' 12.6 = ' + str(timeDiff)) + logPostTiming(enableTimingLog, postStartTime, '12.6') bookmarkStr = \ ' @' + actorNickname + '@' + actorDomain + '\n' # benchmark 9 - if enableTimingLog: - timeDiff = int((time.time() - postStartTime) * 1000) - if timeDiff > 100: - print('TIMING INDIV ' + boxName + ' 9 = ' + str(timeDiff)) + logPostTiming(enableTimingLog, postStartTime, '9') # Show a DM icon for DMs in the inbox timeline if showDMicon: @@ -1385,19 +1294,11 @@ def individualPostAsHtml(allowDownloads: bool, postJsonObject, pageNumberParam, iconsPath, translate) - # benchmark 10 - if enableTimingLog: - timeDiff = int((time.time() - postStartTime) * 1000) - if timeDiff > 100: - print('TIMING INDIV ' + boxName + ' 10 = ' + str(timeDiff)) + logPostTiming(enableTimingLog, postStartTime, '10') isEvent = isEventPost(postJsonObject) - # benchmark 11 - if enableTimingLog: - timeDiff = int((time.time() - postStartTime) * 1000) - if timeDiff > 100: - print('TIMING INDIV ' + boxName + ' 11 = ' + str(timeDiff)) + logPostTiming(enableTimingLog, postStartTime, '11') editStr = getEditIconHtml(baseDir, nickname, domainFull, postJsonObject, actorNickname, @@ -1414,11 +1315,7 @@ def individualPostAsHtml(allowDownloads: bool, timelinePostBookmark, boxName, iconsPath) - # benchmark 12 - if enableTimingLog: - timeDiff = int((time.time() - postStartTime) * 1000) - if timeDiff > 100: - print('TIMING INDIV ' + boxName + ' 12 = ' + str(timeDiff)) + logPostTiming(enableTimingLog, postStartTime, '12') # whether to show a like button hideLikeButtonFile = \ @@ -1437,11 +1334,7 @@ def individualPostAsHtml(allowDownloads: bool, timelinePostBookmark, boxName, iconsPath) - # benchmark 12.5 - if enableTimingLog: - timeDiff = int((time.time() - postStartTime) * 1000) - if timeDiff > 100: - print('TIMING INDIV ' + boxName + ' 12.5 = ' + str(timeDiff)) + logPostTiming(enableTimingLog, postStartTime, '12.5') bookmarkStr = \ getBookmarkIconHtml(nickname, domainFull, @@ -1454,19 +1347,11 @@ def individualPostAsHtml(allowDownloads: bool, timelinePostBookmark, iconsPath) - # benchmark 12.9 - if enableTimingLog: - timeDiff = int((time.time() - postStartTime) * 1000) - if timeDiff > 100: - print('TIMING INDIV ' + boxName + ' 12.9 = ' + str(timeDiff)) + logPostTiming(enableTimingLog, postStartTime, '12.9') isMuted = postIsMuted(baseDir, nickname, domain, postJsonObject, messageId) - # benchmark 13 - if enableTimingLog: - timeDiff = int((time.time() - postStartTime) * 1000) - if timeDiff > 100: - print('TIMING INDIV ' + boxName + ' 13 = ' + str(timeDiff)) + logPostTiming(enableTimingLog, postStartTime, '13') muteStr = \ getMuteIconHtml(isMuted, @@ -1490,11 +1375,7 @@ def individualPostAsHtml(allowDownloads: bool, iconsPath, translate) - # benchmark 13.1 - if enableTimingLog: - timeDiff = int((time.time() - postStartTime) * 1000) - if timeDiff > 100: - print('TIMING INDIV ' + boxName + ' 13.1 = ' + str(timeDiff)) + logPostTiming(enableTimingLog, postStartTime, '13.1') # get the title: x replies to y, x announces y, etc (titleStr2, @@ -1521,11 +1402,7 @@ def individualPostAsHtml(allowDownloads: bool, containerClass) titleStr += titleStr2 - # benchmark 14 - if enableTimingLog: - timeDiff = int((time.time() - postStartTime) * 1000) - if timeDiff > 100: - print('TIMING INDIV ' + boxName + ' 14 = ' + str(timeDiff)) + logPostTiming(enableTimingLog, postStartTime, '14') attachmentStr, galleryStr = \ getPostAttachmentsAsHtml(postJsonObject, boxName, translate, @@ -1536,11 +1413,7 @@ def individualPostAsHtml(allowDownloads: bool, publishedStr = \ getPublishedDateStr(postJsonObject, showPublishedDateOnly) - # benchmark 15 - if enableTimingLog: - timeDiff = int((time.time() - postStartTime) * 1000) - if timeDiff > 100: - print('TIMING INDIV ' + boxName + ' 15 = ' + str(timeDiff)) + logPostTiming(enableTimingLog, postStartTime, '15') publishedLink = messageId # blog posts should have no /statuses/ in their link @@ -1611,11 +1484,7 @@ def individualPostAsHtml(allowDownloads: bool, postJsonObject['object']['summary'], postJsonObject['object']['content']) - # benchmark 16 - if enableTimingLog: - timeDiff = int((time.time() - postStartTime) * 1000) - if timeDiff > 100: - print('TIMING INDIV ' + boxName + ' 16 = ' + str(timeDiff)) + logPostTiming(enableTimingLog, postStartTime, '16') if not isPatch: objectContent = \ @@ -1658,11 +1527,7 @@ def individualPostAsHtml(allowDownloads: bool, else: contentStr += cwContentStr - # benchmark 17 - if enableTimingLog: - timeDiff = int((time.time() - postStartTime) * 1000) - if timeDiff > 100: - print('TIMING INDIV ' + boxName + ' 17 = ' + str(timeDiff)) + logPostTiming(enableTimingLog, postStartTime, '17') if postJsonObject['object'].get('tag') and not isPatch: contentStr = \ @@ -1699,11 +1564,7 @@ def individualPostAsHtml(allowDownloads: bool, else: postHtml = galleryStr - # benchmark 18 - if enableTimingLog: - timeDiff = int((time.time() - postStartTime) * 1000) - if timeDiff > 100: - print('TIMING INDIV ' + boxName + ' 18 = ' + str(timeDiff)) + logPostTiming(enableTimingLog, postStartTime, '18') # save the created html to the recent posts cache if not showPublicOnly and storeToCache and \ @@ -1714,11 +1575,7 @@ def individualPostAsHtml(allowDownloads: bool, updateRecentPostsCache(recentPostsCache, maxRecentPosts, postJsonObject, postHtml) - # benchmark 19 - if enableTimingLog: - timeDiff = int((time.time() - postStartTime) * 1000) - if timeDiff > 100: - print('TIMING INDIV ' + boxName + ' 19 = ' + str(timeDiff)) + logPostTiming(enableTimingLog, postStartTime, '19') return postHtml