本文整理匯總了Python中bzt.modules.aggregator.KPISet.merge_kpis方法的典型用法代碼示例。如果您正苦於以下問題:Python KPISet.merge_kpis方法的具體用法?Python KPISet.merge_kpis怎麽用?Python KPISet.merge_kpis使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類bzt.modules.aggregator.KPISet
的用法示例。
在下文中一共展示了KPISet.merge_kpis方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: point_from_locust
# 需要導入模塊: from bzt.modules.aggregator import KPISet [as 別名]
# 或者: from bzt.modules.aggregator.KPISet import merge_kpis [as 別名]
def point_from_locust(self, ts, sid, data):
"""
:type sid: str
:type ts: str
:type data: dict
:rtype: DataPoint
"""
point = DataPoint(int(ts))
point[DataPoint.SOURCE_ID] = sid
overall = KPISet()
for item in data['stats']:
if ts not in item['num_reqs_per_sec']:
continue
kpiset = KPISet()
kpiset[KPISet.SAMPLE_COUNT] = item['num_reqs_per_sec'][ts]
kpiset[KPISet.CONCURRENCY] = data['user_count']
if item['num_requests']:
avg_rt = (item['total_response_time'] / 1000.0) / item['num_requests']
kpiset.sum_rt = item['num_reqs_per_sec'][ts] * avg_rt
point[DataPoint.CURRENT][item['name']] = kpiset
overall.merge_kpis(kpiset)
point[DataPoint.CURRENT][''] = overall
point.recalculate()
return point
示例2: point_from_locust
# 需要導入模塊: from bzt.modules.aggregator import KPISet [as 別名]
# 或者: from bzt.modules.aggregator.KPISet import merge_kpis [as 別名]
def point_from_locust(timestamp, sid, data):
"""
:type timestamp: str
:type sid: str
:type data: dict
:rtype: DataPoint
"""
point = DataPoint(int(timestamp))
point[DataPoint.SOURCE_ID] = sid
overall = KPISet()
for item in data['stats']:
if timestamp not in item['num_reqs_per_sec']:
continue
kpiset = KPISet()
kpiset[KPISet.SAMPLE_COUNT] = item['num_reqs_per_sec'][timestamp]
kpiset[KPISet.CONCURRENCY] = data['user_count']
kpiset[KPISet.BYTE_COUNT] = item['total_content_length']
if item['num_requests']:
avg_rt = (item['total_response_time'] / 1000.0) / item['num_requests']
kpiset.sum_rt = item['num_reqs_per_sec'][timestamp] * avg_rt
for err in data['errors'].values():
if err['name'] == item['name']:
new_err = KPISet.error_item_skel(err['error'], None, err['occurences'], KPISet.ERRTYPE_ERROR,
Counter())
KPISet.inc_list(kpiset[KPISet.ERRORS], ("msg", err['error']), new_err)
kpiset[KPISet.FAILURES] += err['occurences']
point[DataPoint.CURRENT][item['name']] = kpiset
overall.merge_kpis(kpiset)
point[DataPoint.CURRENT][''] = overall
point.recalculate()
return point