本文整理汇总了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