#-*-coding:utf8-*-
import httplib,datetime
def getRequest(testUrl,requestHeader):
conn = httplib.HTTPConnection("***.****.com")
conn.request(method="GET",url=testUrl,body="",headers=requestHeader)
response = conn.getresponse()
response.read()
def requestTime():
requestHeader = {"Device-Id":"***","Ticket":"***","Local-Version":"1"}
beforeTime = datetime.datetime.now()
getRequest("http://***.***.com/***",requestHeader)
afterTime = datetime.datetime.now()
print (beforeTime,afterTime)
print (afterTime-beforeTime)
requestTime()
ps:可以看出,我这个接口执行花费了34秒,算比较慢的。
网友评论