forked from indymedia/epicyon
Timeline timing function
parent
8f164638c0
commit
e7eff2a111
|
@ -61,6 +61,16 @@ from webapp_question import insertQuestion
|
||||||
from devices import E2EEdecryptMessageFromDevice
|
from devices import E2EEdecryptMessageFromDevice
|
||||||
|
|
||||||
|
|
||||||
|
def logPostTiming(enableTimingLog: bool, postStartTime, debugId: str) -> None:
|
||||||
|
"""Create a log of timings for performance tuning
|
||||||
|
"""
|
||||||
|
if not enableTimingLog:
|
||||||
|
return
|
||||||
|
timeDiff = int((time.time() - postStartTime) * 1000)
|
||||||
|
if timeDiff > 100:
|
||||||
|
print('TIMING INDIV ' + debugId + ' = ' + str(timeDiff))
|
||||||
|
|
||||||
|
|
||||||
def preparePostFromHtmlCache(postHtml: str, boxName: str,
|
def preparePostFromHtmlCache(postHtml: str, boxName: str,
|
||||||
pageNumber: int) -> str:
|
pageNumber: int) -> str:
|
||||||
"""Sets the page number on a cached html post
|
"""Sets the page number on a cached html post
|
||||||
|
@ -861,16 +871,6 @@ def getReplyWithoutDisplayName(translate: {}, iconsPath: str,
|
||||||
replyNickname + '@' + replyDomain + '</a>\n'
|
replyNickname + '@' + replyDomain + '</a>\n'
|
||||||
|
|
||||||
|
|
||||||
def logPostTiming(enableTimingLog: bool, postStartTime, debugId: str) -> None:
|
|
||||||
"""Create a log of timings for performance tuning
|
|
||||||
"""
|
|
||||||
if not enableTimingLog:
|
|
||||||
return
|
|
||||||
timeDiff = int((time.time() - postStartTime) * 1000)
|
|
||||||
if timeDiff > 100:
|
|
||||||
print('TIMING INDIV ' + debugId + ' = ' + str(timeDiff))
|
|
||||||
|
|
||||||
|
|
||||||
def getPostTitleReplyHtml(baseDir: str,
|
def getPostTitleReplyHtml(baseDir: str,
|
||||||
httpPrefix: str,
|
httpPrefix: str,
|
||||||
nickname: str, domain: str,
|
nickname: str, domain: str,
|
||||||
|
|
|
@ -27,6 +27,18 @@ from posts import isModerator
|
||||||
from posts import isEditor
|
from posts import isEditor
|
||||||
|
|
||||||
|
|
||||||
|
def logTimelineTiming(enableTimingLog: bool, timelineStartTime,
|
||||||
|
boxName: str, debugId: str) -> None:
|
||||||
|
"""Create a log of timings for performance tuning
|
||||||
|
"""
|
||||||
|
if not enableTimingLog:
|
||||||
|
return
|
||||||
|
timeDiff = int((time.time() - timelineStartTime) * 1000)
|
||||||
|
if timeDiff > 100:
|
||||||
|
print('TIMELINE TIMING ' +
|
||||||
|
boxName + ' ' + debugId + ' = ' + str(timeDiff))
|
||||||
|
|
||||||
|
|
||||||
def htmlTimeline(cssCache: {}, defaultTimeline: str,
|
def htmlTimeline(cssCache: {}, defaultTimeline: str,
|
||||||
recentPostsCache: {}, maxRecentPosts: int,
|
recentPostsCache: {}, maxRecentPosts: int,
|
||||||
translate: {}, pageNumber: int,
|
translate: {}, pageNumber: int,
|
||||||
|
@ -50,6 +62,8 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str,
|
||||||
authorized: bool) -> str:
|
authorized: bool) -> str:
|
||||||
"""Show the timeline as html
|
"""Show the timeline as html
|
||||||
"""
|
"""
|
||||||
|
enableTimingLog = False
|
||||||
|
|
||||||
timelineStartTime = time.time()
|
timelineStartTime = time.time()
|
||||||
|
|
||||||
accountDir = baseDir + '/accounts/' + nickname + '@' + domain
|
accountDir = baseDir + '/accounts/' + nickname + '@' + domain
|
||||||
|
@ -114,10 +128,7 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str,
|
||||||
# filename of the banner shown at the top
|
# filename of the banner shown at the top
|
||||||
bannerFile, bannerFilename = getBannerFile(baseDir, nickname, domain)
|
bannerFile, bannerFilename = getBannerFile(baseDir, nickname, domain)
|
||||||
|
|
||||||
# benchmark 1
|
logTimelineTiming(enableTimingLog, timelineStartTime, boxName, '1')
|
||||||
timeDiff = int((time.time() - timelineStartTime) * 1000)
|
|
||||||
if timeDiff > 100:
|
|
||||||
print('TIMELINE TIMING ' + boxName + ' 1 = ' + str(timeDiff))
|
|
||||||
|
|
||||||
# is the user a moderator?
|
# is the user a moderator?
|
||||||
if not moderator:
|
if not moderator:
|
||||||
|
@ -127,10 +138,7 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str,
|
||||||
if not editor:
|
if not editor:
|
||||||
editor = isEditor(baseDir, nickname)
|
editor = isEditor(baseDir, nickname)
|
||||||
|
|
||||||
# benchmark 2
|
logTimelineTiming(enableTimingLog, timelineStartTime, boxName, '2')
|
||||||
timeDiff = int((time.time() - timelineStartTime) * 1000)
|
|
||||||
if timeDiff > 100:
|
|
||||||
print('TIMELINE TIMING ' + boxName + ' 2 = ' + str(timeDiff))
|
|
||||||
|
|
||||||
# the appearance of buttons - highlighted or not
|
# the appearance of buttons - highlighted or not
|
||||||
inboxButton = 'button'
|
inboxButton = 'button'
|
||||||
|
@ -217,10 +225,7 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str,
|
||||||
'" src="/' + iconsPath + '/person.png"/></a>\n'
|
'" src="/' + iconsPath + '/person.png"/></a>\n'
|
||||||
break
|
break
|
||||||
|
|
||||||
# benchmark 3
|
logTimelineTiming(enableTimingLog, timelineStartTime, boxName, '3')
|
||||||
timeDiff = int((time.time() - timelineStartTime) * 1000)
|
|
||||||
if timeDiff > 100:
|
|
||||||
print('TIMELINE TIMING ' + boxName + ' 3 = ' + str(timeDiff))
|
|
||||||
|
|
||||||
# moderation / reports button
|
# moderation / reports button
|
||||||
moderationButtonStr = ''
|
moderationButtonStr = ''
|
||||||
|
@ -255,10 +260,7 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str,
|
||||||
|
|
||||||
tlStr = htmlHeaderWithExternalStyle(cssFilename)
|
tlStr = htmlHeaderWithExternalStyle(cssFilename)
|
||||||
|
|
||||||
# benchmark 4
|
logTimelineTiming(enableTimingLog, timelineStartTime, boxName, '4')
|
||||||
timeDiff = int((time.time() - timelineStartTime) * 1000)
|
|
||||||
if timeDiff > 100:
|
|
||||||
print('TIMELINE TIMING ' + boxName + ' 4 = ' + str(timeDiff))
|
|
||||||
|
|
||||||
# if this is a news instance and we are viewing the news timeline
|
# if this is a news instance and we are viewing the news timeline
|
||||||
newsHeader = False
|
newsHeader = False
|
||||||
|
@ -474,10 +476,7 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str,
|
||||||
'" name="submitInfo" value="' + translate['Info'] + '">\n'
|
'" name="submitInfo" value="' + translate['Info'] + '">\n'
|
||||||
tlStr += '</div>\n</form>\n'
|
tlStr += '</div>\n</form>\n'
|
||||||
|
|
||||||
# benchmark 6
|
logTimelineTiming(enableTimingLog, timelineStartTime, boxName, '6')
|
||||||
timeDiff = int((time.time() - timelineStartTime) * 1000)
|
|
||||||
if timeDiff > 100:
|
|
||||||
print('TIMELINE TIMING ' + boxName + ' 6 = ' + str(timeDiff))
|
|
||||||
|
|
||||||
if boxName == 'tlshares':
|
if boxName == 'tlshares':
|
||||||
maxSharesPerAccount = itemsPerPage
|
maxSharesPerAccount = itemsPerPage
|
||||||
|
@ -487,15 +486,7 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str,
|
||||||
maxSharesPerAccount, httpPrefix) +
|
maxSharesPerAccount, httpPrefix) +
|
||||||
htmlFooter())
|
htmlFooter())
|
||||||
|
|
||||||
# benchmark 7
|
logTimelineTiming(enableTimingLog, timelineStartTime, boxName, '7')
|
||||||
timeDiff = int((time.time() - timelineStartTime) * 1000)
|
|
||||||
if timeDiff > 100:
|
|
||||||
print('TIMELINE TIMING ' + boxName + ' 7 = ' + str(timeDiff))
|
|
||||||
|
|
||||||
# benchmark 8
|
|
||||||
timeDiff = int((time.time() - timelineStartTime) * 1000)
|
|
||||||
if timeDiff > 100:
|
|
||||||
print('TIMELINE TIMING ' + boxName + ' 8 = ' + str(timeDiff))
|
|
||||||
|
|
||||||
# page up arrow
|
# page up arrow
|
||||||
if pageNumber > 1:
|
if pageNumber > 1:
|
||||||
|
@ -520,8 +511,6 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str,
|
||||||
|
|
||||||
# show each post in the timeline
|
# show each post in the timeline
|
||||||
for item in timelineJson['orderedItems']:
|
for item in timelineJson['orderedItems']:
|
||||||
timelinePostStartTime = time.time()
|
|
||||||
|
|
||||||
if item['type'] == 'Create' or \
|
if item['type'] == 'Create' or \
|
||||||
item['type'] == 'Announce' or \
|
item['type'] == 'Announce' or \
|
||||||
item['type'] == 'Update':
|
item['type'] == 'Update':
|
||||||
|
@ -543,22 +532,14 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str,
|
||||||
preparePostFromHtmlCache(currTlStr,
|
preparePostFromHtmlCache(currTlStr,
|
||||||
boxName,
|
boxName,
|
||||||
pageNumber)
|
pageNumber)
|
||||||
# benchmark cache post
|
logTimelineTiming(enableTimingLog,
|
||||||
timeDiff = \
|
timelineStartTime,
|
||||||
int((time.time() -
|
boxName, '10')
|
||||||
timelinePostStartTime) * 1000)
|
|
||||||
if timeDiff > 100:
|
|
||||||
print('TIMELINE POST CACHE TIMING ' +
|
|
||||||
boxName + ' = ' + str(timeDiff))
|
|
||||||
|
|
||||||
if not currTlStr:
|
if not currTlStr:
|
||||||
# benchmark cache post
|
logTimelineTiming(enableTimingLog,
|
||||||
timeDiff = \
|
timelineStartTime,
|
||||||
int((time.time() -
|
boxName, '11')
|
||||||
timelinePostStartTime) * 1000)
|
|
||||||
if timeDiff > 100:
|
|
||||||
print('TIMELINE POST DISK TIMING START ' +
|
|
||||||
boxName + ' = ' + str(timeDiff))
|
|
||||||
|
|
||||||
# read the post from disk
|
# read the post from disk
|
||||||
currTlStr = \
|
currTlStr = \
|
||||||
|
@ -578,13 +559,8 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str,
|
||||||
showIndividualPostIcons,
|
showIndividualPostIcons,
|
||||||
manuallyApproveFollowers,
|
manuallyApproveFollowers,
|
||||||
False, True)
|
False, True)
|
||||||
# benchmark cache post
|
logTimelineTiming(enableTimingLog,
|
||||||
timeDiff = \
|
timelineStartTime, boxName, '12')
|
||||||
int((time.time() -
|
|
||||||
timelinePostStartTime) * 1000)
|
|
||||||
if timeDiff > 100:
|
|
||||||
print('TIMELINE POST DISK TIMING ' +
|
|
||||||
boxName + ' = ' + str(timeDiff))
|
|
||||||
|
|
||||||
if currTlStr:
|
if currTlStr:
|
||||||
itemCtr += 1
|
itemCtr += 1
|
||||||
|
@ -625,10 +601,7 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str,
|
||||||
rightColumnStr + ' </td>\n'
|
rightColumnStr + ' </td>\n'
|
||||||
tlStr += ' </tr>\n'
|
tlStr += ' </tr>\n'
|
||||||
|
|
||||||
# benchmark 9
|
logTimelineTiming(enableTimingLog, timelineStartTime, boxName, '9')
|
||||||
timeDiff = int((time.time() - timelineStartTime) * 1000)
|
|
||||||
if timeDiff > 100:
|
|
||||||
print('TIMELINE TIMING ' + boxName + ' 9 = ' + str(timeDiff))
|
|
||||||
|
|
||||||
tlStr += ' </tbody>\n'
|
tlStr += ' </tbody>\n'
|
||||||
tlStr += '</table>\n'
|
tlStr += '</table>\n'
|
||||||
|
|
Loading…
Reference in New Issue