本文整理汇总了Python中stopwatch.Stopwatch.measure方法的典型用法代码示例。如果您正苦于以下问题:Python Stopwatch.measure方法的具体用法?Python Stopwatch.measure怎么用?Python Stopwatch.measure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stopwatch.Stopwatch
的用法示例。
在下文中一共展示了Stopwatch.measure方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: do_GET
# 需要导入模块: from stopwatch import Stopwatch [as 别名]
# 或者: from stopwatch.Stopwatch import measure [as 别名]
def do_GET(self):
if 0:
self.send_response(200)
self.end_headers()
self.wfile.write(b'fast')
return
watch = Stopwatch()
global ourData
try:
args = self.path.split('?')
if len(args)<2:
print("no size arg", args)
return
sizearg = int(args[1])
front = '[%s]\n' % sizearg
except Exception as e:
self.send_response(500)
self.end_headers()
err_out = str(e).encode()
self.wfile.write(err_out)
return
self.send_response(200)
self.end_headers()
self.wfile.write(front.encode())
#print('len:', len(ourData.slices.get(sizearg,'missing')))
self.wfile.write( ourData.slices.get(sizearg,'missing') )
watch.measure()
示例2: doDB_Work
# 需要导入模块: from stopwatch import Stopwatch [as 别名]
# 或者: from stopwatch.Stopwatch import measure [as 别名]
def doDB_Work(limit=9999):
dbServer = r'jg-pc\jg1'
dbName = 'Ajour_System_A/S_10aee6e8b7dd4f4a8fd0cbf9cedf91cb'
theDBCfg = { 'server': dbServer, 'db': dbName, 'user': 'sa', 'pwd': 'morOg234' }
with getConn(theDBCfg) as conn:
csr = conn.cursor()
sw = Stopwatch()
a = selectFromDB(csr)
sw.measure()
print(len(a))
示例3: getBCbyVsId
# 需要导入模块: from stopwatch import Stopwatch [as 别名]
# 或者: from stopwatch.Stopwatch import measure [as 别名]
def getBCbyVsId(
vsId = 'B14462',
releaseId='624d9489-0f8c-48db-99f9-67701a040742'
):
global headers, url
bcUrl = url + '/api/v1/BuildingComponent/VSID/{vsId}/Release/{releaseId}'.format(vsId=vsId, releaseId=releaseId)
watch = Stopwatch('req')
r = requests.get( bcUrl, headers=headers)
watch.measure()
logIfBad(r)
exes = json.loads(r.text)
print(len(r.text))
if 0:
pprint.pprint(exes)
示例4: getBC_chunk
# 需要导入模块: from stopwatch import Stopwatch [as 别名]
# 或者: from stopwatch.Stopwatch import measure [as 别名]
def getBC_chunk(chunkSet):
global headers, url
bcUrl = url + '/api/v1/BuildingComponent/VSIDs/Release/624d9489-0f8c-48db-99f9-67701a040742?' + chunkSet #bcArgs
print(bcUrl)
#return
watch = Stopwatch('req')
r = requests.post( bcUrl, headers=headers)
watch.measure()
logIfBad(r)
exes = json.loads(r.text)
print('len:', len(r.text))
with open( 'BCs.json', "w") as outfile:
json.dump(exes, outfile, indent=2)
if 0:
pprint.pprint(exes)
示例5: getBCs
# 需要导入模块: from stopwatch import Stopwatch [as 别名]
# 或者: from stopwatch.Stopwatch import measure [as 别名]
def getBCs(
releaseId='624d9489-0f8c-48db-99f9-67701a040742'
):
global headers, url
bcUrl = url + '/api/v1/BuildingComponent/VSIDs/Release/{releaseId}?VSID1=B33321&VSID2=B96932&VSID3=B75326&VSID4=B36547&VSID5=B20553&VSID6=B59061&VSID7=B58491&VSID8=B80296&VSID9=B81223'.format(releaseId=releaseId)
print(bcUrl)
watch = Stopwatch('req')
r = requests.post( bcUrl, headers=headers)
watch.measure()
logIfBad(r)
exes = json.loads(r.text)
print(len(r.text))
with open( 'BCs.json', "w") as outfile:
json.dump(exes, outfile, indent=2)
if 0:
pprint.pprint(exes)
示例6: GetDataForCatsFromServer
# 需要导入模块: from stopwatch import Stopwatch [as 别名]
# 或者: from stopwatch.Stopwatch import measure [as 别名]
def GetDataForCatsFromServer(cat, desc, orgId, orgName, action):
#action = 'GetData'
#action = 'GetDataTest'
reqUrl = base_url + '/api/Search/' + action #GetData
SearchDataRequest = {
'ContextTypes': 'Organization',
'BuiltInCategories': [cat],
'Version': '2019',
'OrgId': orgId
}
sw = Stopwatch()
while True:
verbose = False
if verbose:
print("before GetData", SearchDataRequest['BuiltInCategories'], desc, reqUrl )
r = requests.post( reqUrl, json = SearchDataRequest, headers=headers)
if r.status_code == 200:
break
print("after GetData", r.status_code, orgId, orgName)
if r.status_code == 401:
ensureLogin()
else:
print(r.text)
raise
break # or even throw?
sw = Stopwatch() # start new stopwatch.
m = sw.measure(silent=True)
return (r,m)
示例7: getPrice_chunk
# 需要导入模块: from stopwatch import Stopwatch [as 别名]
# 或者: from stopwatch.Stopwatch import measure [as 别名]
def getPrice_chunk(chunkSet, chunkIx):
global headers, url
releaseID = '624d9489-0f8c-48db-99f9-67701a040742'
priceUrl = url + '/api/v1/BuildingComponent/Calculate/Release/%s?' % releaseID
priceUrl += chunkSet
print(chunkIx, priceUrl)
#return
watch = Stopwatch('req')
r = requests.post( priceUrl, headers=headers)
watch.measure()
logIfBad(r)
prices = json.loads(r.text)
if 0:
pprint.pprint(prices)
with open( 'prices.json', "w") as outfile:
json.dump(prices, outfile, indent=2)
示例8: getPrices
# 需要导入模块: from stopwatch import Stopwatch [as 别名]
# 或者: from stopwatch.Stopwatch import measure [as 别名]
def getPrices():
global headers, url
releaseID = '624d9489-0f8c-48db-99f9-67701a040742'
priceUrl = url + '/api/v1/BuildingComponent/Calculate/Release/%s?' % releaseID
priceUrl += 'id1=d03b8b89-fb70-47da-9a18-011132b22921&id2=32e920bb-e927-4a10-ad85-14c32bd197ff&id3=3dbf3ce5-f7e5-4745-bf18-1bd766c1b54d'
priceUrl += '&amount1=10&amount2=10&amount3=10'
priceUrl += "&yourCalculationId=1246" #{myRandomCalculationNumber}
print(priceUrl)
watch = Stopwatch('req')
r = requests.post( priceUrl, headers=headers)
watch.measure()
logIfBad(r)
prices = json.loads(r.text)
if 0:
pprint.pprint(prices)
with open( 'prices.json', "w") as outfile:
json.dump(prices, outfile, indent=2)
示例9: getBCbyGroup
# 需要导入模块: from stopwatch import Stopwatch [as 别名]
# 或者: from stopwatch.Stopwatch import measure [as 别名]
def getBCbyGroup( # get the BCs within a BC-group.
groupId = 'B14462',
releaseId='624d9489-0f8c-48db-99f9-67701a040742'
):
global headers, url
bcUrl = url + '/api/v1/BuildingComponent/BuildingComponentGroup/{groupId}/Release/{releaseId}'.format(groupId=groupId, releaseId=releaseId)
watch = Stopwatch('req')
r = requests.get( bcUrl, headers=headers)
watch.measure(show=False)
logIfBad(r)
exes = json.loads(r.text)
if 0:
print(len(r.text))
if 0:
pprint.pprint(exes)
exes = exes['buildingComponents']
return exes
示例10: GetToken_Password
# 需要导入模块: from stopwatch import Stopwatch [as 别名]
# 或者: from stopwatch.Stopwatch import measure [as 别名]
def GetToken_Password(): # oauth, exchange a password for a token.
global env, url
print(env['username'], env['password'])
tokenReq = {
'grant_type': 'password',
'username': env['username'], #+'2',
'password': env['password'],
'client_id': env['client_id'],
'client_secret': env['client_secret'] #+'2'
}
token_url = url + '/token'
print('before', token_url)
watch = Stopwatch('req')
r = requests.post(token_url, tokenReq)
watch.measure()
logIfBad(r)
return r