本文整理汇总了Python中hdrh.histogram.HdrHistogram.get_percentile_to_value_dict方法的典型用法代码示例。如果您正苦于以下问题:Python HdrHistogram.get_percentile_to_value_dict方法的具体用法?Python HdrHistogram.get_percentile_to_value_dict怎么用?Python HdrHistogram.get_percentile_to_value_dict使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hdrh.histogram.HdrHistogram
的用法示例。
在下文中一共展示了HdrHistogram.get_percentile_to_value_dict方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: consolidate_results
# 需要导入模块: from hdrh.histogram import HdrHistogram [as 别名]
# 或者: from hdrh.histogram.HdrHistogram import get_percentile_to_value_dict [as 别名]
def consolidate_results(results):
all_res = {'tool': 'wrk2'}
total_count = len(results)
if not total_count:
return all_res
for key in ['http_rps', 'http_total_req', 'http_sock_err',
'http_sock_timeout', 'http_throughput_kbytes']:
all_res[key] = 0
for item in results:
if (key in item['results']):
all_res[key] += item['results'][key]
all_res[key] = int(all_res[key])
if 'latency_stats' in results[0]['results']:
# for item in results:
# print item['results']['latency_stats']
all_res['latency_stats'] = []
histogram = HdrHistogram(1, 24 * 3600 * 1000 * 1000, 2)
for item in results:
histogram.decode_and_add(item['results']['latency_stats'])
perc_list = [50, 75, 90, 99, 99.9, 99.99, 99.999]
latency_dict = histogram.get_percentile_to_value_dict(perc_list)
for key, value in latency_dict.iteritems():
all_res['latency_stats'].append([key, value])
all_res['latency_stats'].sort()
return all_res
示例2: consolidate_results
# 需要导入模块: from hdrh.histogram import HdrHistogram [as 别名]
# 或者: from hdrh.histogram.HdrHistogram import get_percentile_to_value_dict [as 别名]
def consolidate_results(results):
err_flag = False
all_res = {'tool': 'wrk2'}
total_count = len(results)
if not total_count:
return all_res
for key in ['http_rps', 'http_total_req', 'http_sock_err',
'http_sock_timeout', 'http_throughput_kbytes']:
all_res[key] = 0
for item in results:
all_res[key] += item['results'].get(key, 0)
all_res[key] = int(all_res[key])
if 'latency_stats' in results[0]['results']:
# for item in results:
# print item['results']['latency_stats']
all_res['latency_stats'] = []
histogram = HdrHistogram(1, 24 * 3600 * 1000 * 1000, 2)
for item in results:
if 'latency_stats' in item['results']:
histogram.decode_and_add(item['results']['latency_stats'])
else:
err_flag = True
perc_list = [50, 75, 90, 99, 99.9, 99.99, 99.999]
latency_dict = histogram.get_percentile_to_value_dict(perc_list)
for key, value in latency_dict.iteritems():
all_res['latency_stats'].append([key, value])
all_res['latency_stats'].sort()
if err_flag:
LOG.warning('Unable to find latency_stats from the result dictionary, this '
'may indicate that the test application on VM exited abnormally.')
return all_res