Remove POST benchmarks

main
Bob Mottram 2019-11-16 13:06:15 +00:00
parent 2e8691f4ba
commit c0f4f502c5
1 changed files with 0 additions and 81 deletions

View File

@ -857,14 +857,6 @@ class PubServer(BaseHTTPRequestHandler):
timeDiff='0'+timeDiff
print('BENCHMARK GET|'+timeDiff+'|'+self.path)
def _benchmarkPOST(self,POSTstartTime,postID: int):
if self.server.debug:
timeDiff=str(int((time.time()-POSTstartTime)*1000))
timeDiffLen=len(timeDiff)
for i in range(6-timeDiffLen):
timeDiff='0'+timeDiff
print('BENCHMARK POST|'+timeDiff+'|'+self.path+'|ID'+str(postID))
def _benchmarkPOSTtimings(self,POSTstartTime,POSTtimings: [],postID: int):
"""Updates a list containing how long each segment of POST takes
"""
@ -3287,7 +3279,6 @@ class PubServer(BaseHTTPRequestHandler):
if currTimePOST-self.server.lastPOST==0:
self.send_response(429)
self.end_headers()
self._benchmarkPOST(POSTstartTime,1)
return
self.server.lastPOST=currTimePOST
@ -3297,7 +3288,6 @@ class PubServer(BaseHTTPRequestHandler):
self.send_response(400)
self.end_headers()
self.server.POSTbusy=False
self._benchmarkPOST(POSTstartTime,2)
return
# remove any trailing slashes from the path
@ -3338,7 +3328,6 @@ class PubServer(BaseHTTPRequestHandler):
self.send_response(401)
self.end_headers()
self.server.POSTbusy=False
self._benchmarkPOST(POSTstartTime,3)
return
loginParams=self.rfile.read(length).decode('utf-8')
loginNickname,loginPassword,register= \
@ -3353,7 +3342,6 @@ class PubServer(BaseHTTPRequestHandler):
loginNickname,loginPassword):
self.server.POSTbusy=False
self._redirect_headers('/login',cookie)
self._benchmarkPOST(POSTstartTime,4)
return
authHeader=createBasicAuthHeader(loginNickname,loginPassword)
if not authorizeBasic(self.server.baseDir,'/users/'+ \
@ -3361,7 +3349,6 @@ class PubServer(BaseHTTPRequestHandler):
print('Login failed: '+loginNickname)
self._clearLoginDetails(loginNickname)
self.server.POSTbusy=False
self._benchmarkPOST(POSTstartTime,5)
return
else:
if isSuspended(self.server.baseDir,loginNickname):
@ -3369,7 +3356,6 @@ class PubServer(BaseHTTPRequestHandler):
self._login_headers('text/html',len(msg))
self._write(msg)
self.server.POSTbusy=False
self._benchmarkPOST(POSTstartTime,6)
return
# login success - redirect with authorization
print('Login success: '+loginNickname)
@ -3416,12 +3402,10 @@ class PubServer(BaseHTTPRequestHandler):
self.send_header('X-Robots-Tag','noindex')
self.end_headers()
self.server.POSTbusy=False
self._benchmarkPOST(POSTstartTime,7)
return
self.send_response(200)
self.end_headers()
self.server.POSTbusy=False
self._benchmarkPOST(POSTstartTime,8)
return
self._benchmarkPOSTtimings(POSTstartTime,POSTtimings,2)
@ -3439,14 +3423,12 @@ class PubServer(BaseHTTPRequestHandler):
print('WARN: nickname not found in '+actorStr)
self._redirect_headers(actorStr,cookie)
self.server.POSTbusy=False
self._benchmarkPOST(POSTstartTime,9)
return
length = int(self.headers['Content-length'])
if length>self.server.maxPostLength:
print('Maximum profile data length exceeded '+str(length))
self._redirect_headers(actorStr,cookie)
self.server.POSTbusy=False
self._benchmarkPOST(POSTstartTime,10)
return
# read the bytes of the http form POST
@ -3726,11 +3708,9 @@ class PubServer(BaseHTTPRequestHandler):
deactivateAccount(self.server.baseDir,nickname,self.server.domain)
self._clearLoginDetails(nickname)
self.server.POSTbusy=False
self._benchmarkPOST(POSTstartTime,11)
return
self._redirect_headers(actorStr,cookie)
self.server.POSTbusy=False
self._benchmarkPOST(POSTstartTime,12)
return
self._benchmarkPOSTtimings(POSTstartTime,POSTtimings,3)
@ -3759,7 +3739,6 @@ class PubServer(BaseHTTPRequestHandler):
self._login_headers('text/html',len(msg))
self._write(msg)
self.server.POSTbusy=False
self._benchmarkPOST(POSTstartTime,14)
return
elif moderationStr.startswith('submitBlock'):
moderationButton='block'
@ -3845,7 +3824,6 @@ class PubServer(BaseHTTPRequestHandler):
self.server.debug)
self._redirect_headers(actorStr+'/moderation',cookie)
self.server.POSTbusy=False
self._benchmarkPOST(POSTstartTime,15)
return
self._benchmarkPOSTtimings(POSTstartTime,POSTtimings,4)
@ -3875,7 +3853,6 @@ class PubServer(BaseHTTPRequestHandler):
self.server.domainFull+self.path.replace('/question','')
nickname=getNicknameFromActor(actor)
if not nickname:
self._benchmarkPOST(POSTstartTime,16)
self._redirect_headers(actor+'/inbox?page='+ \
str(pageNumber),cookie)
self.server.POSTbusy=False
@ -3922,7 +3899,6 @@ class PubServer(BaseHTTPRequestHandler):
print('ERROR: unable to create vote')
self._redirect_headers(actor+'/inbox?page='+str(pageNumber),cookie)
self.server.POSTbusy=False
self._benchmarkPOST(POSTstartTime,17)
return
self._benchmarkPOSTtimings(POSTstartTime,POSTtimings,6)
@ -3970,7 +3946,6 @@ class PubServer(BaseHTTPRequestHandler):
self._login_headers('text/html',len(msg))
self._write(msg)
self.server.POSTbusy=False
self._benchmarkPOST(POSTstartTime,18)
return
elif searchStr.startswith('*'):
# skill search
@ -3985,7 +3960,6 @@ class PubServer(BaseHTTPRequestHandler):
self._login_headers('text/html',len(msg))
self._write(msg)
self.server.POSTbusy=False
self._benchmarkPOST(POSTstartTime,19)
return
elif '@' in searchStr:
# profile search
@ -4011,12 +3985,10 @@ class PubServer(BaseHTTPRequestHandler):
self._login_headers('text/html',len(msg))
self._write(msg)
self.server.POSTbusy=False
self._benchmarkPOST(POSTstartTime,20)
return
else:
self._redirect_headers(actorStr+'/search',cookie)
self.server.POSTbusy=False
self._benchmarkPOST(POSTstartTime,21)
return
elif searchStr.startswith(':') or \
searchStr.lower().strip('\n').endswith(' emoji'):
@ -4033,7 +4005,6 @@ class PubServer(BaseHTTPRequestHandler):
self._login_headers('text/html',len(msg))
self._write(msg)
self.server.POSTbusy=False
self._benchmarkPOST(POSTstartTime,22)
return
else:
# shared items search
@ -4050,9 +4021,7 @@ class PubServer(BaseHTTPRequestHandler):
self._login_headers('text/html',len(msg))
self._write(msg)
self.server.POSTbusy=False
self._benchmarkPOST(POSTstartTime,23)
return
self._benchmarkPOST(POSTstartTime,24)
self._redirect_headers(actorStr+'/inbox',cookie)
self.server.POSTbusy=False
return
@ -4080,7 +4049,6 @@ class PubServer(BaseHTTPRequestHandler):
shareNickname,shareDomain,shareName)
self._redirect_headers(originPathStr+'/tlshares',cookie)
self.server.POSTbusy=False
self._benchmarkPOST(POSTstartTime,25)
return
self._benchmarkPOSTtimings(POSTstartTime,POSTtimings,8)
@ -4126,7 +4094,6 @@ class PubServer(BaseHTTPRequestHandler):
self._redirect_headers(originPathStr+'/outbox?page='+ \
str(pageNumber),cookie)
self.server.POSTbusy=False
self._benchmarkPOST(POSTstartTime,26)
return
self._benchmarkPOSTtimings(POSTstartTime,POSTtimings,9)
@ -4144,7 +4111,6 @@ class PubServer(BaseHTTPRequestHandler):
followingActor=followingActor.split('&')[0]
self._redirect_headers(followingActor,cookie)
self.server.POSTbusy=False
self._benchmarkPOST(POSTstartTime,27)
return
if '&submitYes=' in followConfirmParams:
followingActor= \
@ -4179,7 +4145,6 @@ class PubServer(BaseHTTPRequestHandler):
self.server.projectVersion)
self._redirect_headers(originPathStr,cookie)
self.server.POSTbusy=False
self._benchmarkPOST(POSTstartTime,28)
return
self._benchmarkPOSTtimings(POSTstartTime,POSTtimings,10)
@ -4228,7 +4193,6 @@ class PubServer(BaseHTTPRequestHandler):
self._postToOutboxThread(unfollowJson)
self._redirect_headers(originPathStr,cookie)
self.server.POSTbusy=False
self._benchmarkPOST(POSTstartTime,29)
return
self._benchmarkPOSTtimings(POSTstartTime,POSTtimings,11)
@ -4241,7 +4205,6 @@ class PubServer(BaseHTTPRequestHandler):
print('WARN: unable to find nickname in '+originPathStr)
self._redirect_headers(originPathStr,cookie)
self.server.POSTbusy=False
self._benchmarkPOST(POSTstartTime,30)
return
length = int(self.headers['Content-length'])
blockConfirmParams=self.rfile.read(length).decode('utf-8')
@ -4255,7 +4218,6 @@ class PubServer(BaseHTTPRequestHandler):
print('WARN: unable to find nickname in '+blockingActor)
self._redirect_headers(originPathStr,cookie)
self.server.POSTbusy=False
self._benchmarkPOST(POSTstartTime,31)
return
blockingDomain,blockingPort=getDomainFromActor(blockingActor)
blockingDomainFull=blockingDomain
@ -4276,7 +4238,6 @@ class PubServer(BaseHTTPRequestHandler):
blockingNickname,blockingDomainFull)
self._redirect_headers(originPathStr,cookie)
self.server.POSTbusy=False
self._benchmarkPOST(POSTstartTime,32)
return
self._benchmarkPOSTtimings(POSTstartTime,POSTtimings,12)
@ -4289,7 +4250,6 @@ class PubServer(BaseHTTPRequestHandler):
print('WARN: unable to find nickname in '+originPathStr)
self._redirect_headers(originPathStr,cookie)
self.server.POSTbusy=False
self._benchmarkPOST(POSTstartTime,33)
return
length = int(self.headers['Content-length'])
blockConfirmParams=self.rfile.read(length).decode('utf-8')
@ -4303,7 +4263,6 @@ class PubServer(BaseHTTPRequestHandler):
print('WARN: unable to find nickname in '+blockingActor)
self._redirect_headers(originPathStr,cookie)
self.server.POSTbusy=False
self._benchmarkPOST(POSTstartTime,34)
return
blockingDomain,blockingPort= \
getDomainFromActor(blockingActor)
@ -4327,7 +4286,6 @@ class PubServer(BaseHTTPRequestHandler):
blockingNickname,blockingDomainFull)
self._redirect_headers(originPathStr,cookie)
self.server.POSTbusy=False
self._benchmarkPOST(POSTstartTime,35)
return
self._benchmarkPOSTtimings(POSTstartTime,POSTtimings,13)
@ -4342,7 +4300,6 @@ class PubServer(BaseHTTPRequestHandler):
print('WARN: unable to find nickname in '+originPathStr)
self._redirect_headers(originPathStr,cookie)
self.server.POSTbusy=False
self._benchmarkPOST(POSTstartTime,36)
return
length = int(self.headers['Content-length'])
optionsConfirmParams= \
@ -4374,7 +4331,6 @@ class PubServer(BaseHTTPRequestHandler):
print('WARN: unable to find nickname in '+optionsActor)
self._redirect_headers(originPathStr,cookie)
self.server.POSTbusy=False
self._benchmarkPOST(POSTstartTime,37)
return
optionsDomain,optionsPort=getDomainFromActor(optionsActor)
optionsDomainFull=optionsDomain
@ -4393,7 +4349,6 @@ class PubServer(BaseHTTPRequestHandler):
print('Viewing '+optionsActor)
self._redirect_headers(optionsActor,cookie)
self.server.POSTbusy=False
self._benchmarkPOST(POSTstartTime,38)
return
if '&submitBlock=' in optionsConfirmParams:
if self.server.debug:
@ -4413,7 +4368,6 @@ class PubServer(BaseHTTPRequestHandler):
self._set_headers('text/html',len(msg),cookie)
self._write(msg)
self.server.POSTbusy=False
self._benchmarkPOST(POSTstartTime,39)
return
if '&submitFollow=' in optionsConfirmParams:
if self.server.debug:
@ -4426,7 +4380,6 @@ class PubServer(BaseHTTPRequestHandler):
self._set_headers('text/html',len(msg),cookie)
self._write(msg)
self.server.POSTbusy=False
self._benchmarkPOST(POSTstartTime,40)
return
if '&submitUnfollow=' in optionsConfirmParams:
if self.server.debug:
@ -4439,7 +4392,6 @@ class PubServer(BaseHTTPRequestHandler):
self._set_headers('text/html',len(msg),cookie)
self._write(msg)
self.server.POSTbusy=False
self._benchmarkPOST(POSTstartTime,41)
return
if '&submitDM=' in optionsConfirmParams:
if self.server.debug:
@ -4453,7 +4405,6 @@ class PubServer(BaseHTTPRequestHandler):
self._set_headers('text/html',len(msg),cookie)
self._write(msg)
self.server.POSTbusy=False
self._benchmarkPOST(POSTstartTime,42)
return
if '&submitSnooze=' in optionsConfirmParams:
thisActor=self.path.split('/personoptions')[0]
@ -4462,7 +4413,6 @@ class PubServer(BaseHTTPRequestHandler):
if '/users/' in thisActor:
nickname=thisActor.split('/users/')[1]
personSnooze(self.server.baseDir,nickname,self.server.domain,optionsActor)
self._benchmarkPOST(POSTstartTime,43)
self._redirect_headers(thisActor+ \
'/inbox?page='+str(pageNumber),cookie)
self.server.POSTbusy=False
@ -4474,7 +4424,6 @@ class PubServer(BaseHTTPRequestHandler):
if '/users/' in thisActor:
nickname=thisActor.split('/users/')[1]
personUnsnooze(self.server.baseDir,nickname,self.server.domain,optionsActor)
self._benchmarkPOST(POSTstartTime,44)
self._redirect_headers(thisActor+ \
'/inbox?page='+str(pageNumber),cookie)
self.server.POSTbusy=False
@ -4490,10 +4439,8 @@ class PubServer(BaseHTTPRequestHandler):
self._set_headers('text/html',len(msg),cookie)
self._write(msg)
self.server.POSTbusy=False
self._benchmarkPOST(POSTstartTime,45)
return
self._benchmarkPOST(POSTstartTime,46)
self._redirect_headers(originPathStr,cookie)
self.server.POSTbusy=False
return
@ -4505,7 +4452,6 @@ class PubServer(BaseHTTPRequestHandler):
nickname=self.path.split('/users/')[1]
if '/' in nickname:
nickname=nickname.split('/')[0]
self._benchmarkPOST(POSTstartTime,47)
self._redirect_headers('/users/'+nickname+ \
'/inbox?page='+str(pageNumber),cookie)
self.server.POSTbusy=False
@ -4515,7 +4461,6 @@ class PubServer(BaseHTTPRequestHandler):
nickname=self.path.split('/users/')[1]
if '/' in nickname:
nickname=nickname.split('/')[0]
self._benchmarkPOST(POSTstartTime,48)
self._redirect_headers('/users/'+nickname+ \
'/inbox?page='+str(pageNumber),cookie)
self.server.POSTbusy=False
@ -4525,7 +4470,6 @@ class PubServer(BaseHTTPRequestHandler):
nickname=self.path.split('/users/')[1]
if '/' in nickname:
nickname=nickname.split('/')[0]
self._benchmarkPOST(POSTstartTime,49)
self._redirect_headers('/users/'+nickname+ \
'/inbox?page='+str(pageNumber),cookie)
self.server.POSTbusy=False
@ -4535,7 +4479,6 @@ class PubServer(BaseHTTPRequestHandler):
nickname=self.path.split('/users/')[1]
if '/' in nickname:
nickname=nickname.split('/')[0]
self._benchmarkPOST(POSTstartTime,50)
self._redirect_headers('/users/'+nickname+ \
'/inbox?page='+str(pageNumber),cookie)
self.server.POSTbusy=False
@ -4545,7 +4488,6 @@ class PubServer(BaseHTTPRequestHandler):
nickname=self.path.split('/users/')[1]
if '/' in nickname:
nickname=nickname.split('/')[0]
self._benchmarkPOST(POSTstartTime,51)
self._redirect_headers('/users/'+nickname+ \
'/inbox?page='+str(pageNumber),cookie)
self.server.POSTbusy=False
@ -4555,7 +4497,6 @@ class PubServer(BaseHTTPRequestHandler):
nickname=self.path.split('/users/')[1]
if '/' in nickname:
nickname=nickname.split('/')[0]
self._benchmarkPOST(POSTstartTime,52)
self._redirect_headers('/users/'+nickname+ \
'/shares?page='+str(pageNumber),cookie)
self.server.POSTbusy=False
@ -4573,7 +4514,6 @@ class PubServer(BaseHTTPRequestHandler):
self.send_response(405)
self.end_headers()
self.server.POSTbusy=False
self._benchmarkPOST(POSTstartTime,53)
return
self._benchmarkPOSTtimings(POSTstartTime,POSTtimings,16)
@ -4589,7 +4529,6 @@ class PubServer(BaseHTTPRequestHandler):
self.send_response(400)
self.end_headers()
self.server.POSTbusy=False
self._benchmarkPOST(POSTstartTime,54)
return
self._benchmarkPOSTtimings(POSTstartTime,POSTtimings,17)
@ -4606,7 +4545,6 @@ class PubServer(BaseHTTPRequestHandler):
self.send_response(400)
self.end_headers()
self.server.POSTbusy=False
self._benchmarkPOST(POSTstartTime,55)
return
else:
if length>self.server.maxMediaSize:
@ -4614,7 +4552,6 @@ class PubServer(BaseHTTPRequestHandler):
self.send_response(400)
self.end_headers()
self.server.POSTbusy=False
self._benchmarkPOST(POSTstartTime,56)
return
# receive images to the outbox
@ -4626,14 +4563,12 @@ class PubServer(BaseHTTPRequestHandler):
self.send_response(403)
self.end_headers()
self.server.POSTbusy=False
self._benchmarkPOST(POSTstartTime,57)
return
pathUsersSection=self.path.split('/users/')[1]
if '/' not in pathUsersSection:
self.send_response(404)
self.end_headers()
self.server.POSTbusy=False
self._benchmarkPOST(POSTstartTime,58)
return
self.postFromNickname=pathUsersSection.split('/')[0]
accountsDir= \
@ -4643,7 +4578,6 @@ class PubServer(BaseHTTPRequestHandler):
self.send_response(404)
self.end_headers()
self.server.POSTbusy=False
self._benchmarkPOST(POSTstartTime,59)
return
mediaBytes=self.rfile.read(length)
mediaFilenameBase=accountsDir+'/upload'
@ -4661,7 +4595,6 @@ class PubServer(BaseHTTPRequestHandler):
self.send_response(201)
self.end_headers()
self.server.POSTbusy=False
self._benchmarkPOST(POSTstartTime,60)
return
# refuse to receive non-json content
@ -4677,7 +4610,6 @@ class PubServer(BaseHTTPRequestHandler):
self.send_response(400)
self.end_headers()
self.server.POSTbusy=False
self._benchmarkPOST(POSTstartTime,61)
return
if self.server.debug:
@ -4698,7 +4630,6 @@ class PubServer(BaseHTTPRequestHandler):
print('WARN: post to shared inbox is too long '+str(length)+' bytes')
self._400()
self.server.POSTbusy=False
self._benchmarkPOST(POSTstartTime,125)
return
messageBytes=self.rfile.read(length)
@ -4710,7 +4641,6 @@ class PubServer(BaseHTTPRequestHandler):
print('WARN: post to shared inbox is too long '+str(lenMessage)+' bytes')
self._400()
self.server.POSTbusy=False
self._benchmarkPOST(POSTstartTime,125)
return
# convert the raw bytes to json
@ -4727,7 +4657,6 @@ class PubServer(BaseHTTPRequestHandler):
self.send_response(201)
self.end_headers()
self.server.POSTbusy=False
self._benchmarkPOST(POSTstartTime,62)
return
else:
if self.server.debug:
@ -4735,7 +4664,6 @@ class PubServer(BaseHTTPRequestHandler):
self.send_response(403)
self.end_headers()
self.server.POSTbusy=False
self._benchmarkPOST(POSTstartTime,63)
return
self._benchmarkPOSTtimings(POSTstartTime,POSTtimings,20)
@ -4753,7 +4681,6 @@ class PubServer(BaseHTTPRequestHandler):
self.send_response(403)
self.end_headers()
self.server.POSTbusy=False
self._benchmarkPOST(POSTstartTime,64)
return
self._benchmarkPOSTtimings(POSTstartTime,POSTtimings,21)
@ -4765,7 +4692,6 @@ class PubServer(BaseHTTPRequestHandler):
self.send_response(403)
self.end_headers()
self.server.POSTbusy=False
self._benchmarkPOST(POSTstartTime,66)
return
self._benchmarkPOSTtimings(POSTstartTime,POSTtimings,22)
@ -4779,7 +4705,6 @@ class PubServer(BaseHTTPRequestHandler):
self.send_response(403)
self.end_headers()
self.server.POSTbusy=False
self._benchmarkPOST(POSTstartTime,65)
return
if self.server.debug:
@ -4804,13 +4729,11 @@ class PubServer(BaseHTTPRequestHandler):
self.send_response(200)
self.end_headers()
self.server.POSTbusy=False
self._benchmarkPOST(POSTstartTime,67)
return
if queueStatus==1:
self.send_response(503)
self.end_headers()
self.server.POSTbusy=False
self._benchmarkPOST(POSTstartTime,68)
return
if self.server.debug:
print('_updateInboxQueue exited without doing anything')
@ -4820,25 +4743,21 @@ class PubServer(BaseHTTPRequestHandler):
self.send_response(403)
self.end_headers()
self.server.POSTbusy=False
self._benchmarkPOST(POSTstartTime,69)
return
else:
if self.path == '/sharedInbox' or self.path == '/inbox':
print('DEBUG: POST to shared inbox')
self._benchmarkPOST(POSTstartTime,700)
queueStatus= \
self._updateInboxQueue('inbox',messageJson,messageBytes)
if queueStatus==0:
self.send_response(200)
self.end_headers()
self.server.POSTbusy=False
self._benchmarkPOST(POSTstartTime,70)
return
if queueStatus==1:
self.send_response(503)
self.end_headers()
self.server.POSTbusy=False
self._benchmarkPOST(POSTstartTime,71)
return
self.send_response(200)
self.end_headers()