本文整理汇总了Python中perfrunner.helpers.remote.RemoteHelper.read_bandwidth_stats方法的典型用法代码示例。如果您正苦于以下问题:Python RemoteHelper.read_bandwidth_stats方法的具体用法?Python RemoteHelper.read_bandwidth_stats怎么用?Python RemoteHelper.read_bandwidth_stats使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类perfrunner.helpers.remote.RemoteHelper
的用法示例。
在下文中一共展示了RemoteHelper.read_bandwidth_stats方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MetricHelper
# 需要导入模块: from perfrunner.helpers.remote import RemoteHelper [as 别名]
# 或者: from perfrunner.helpers.remote.RemoteHelper import read_bandwidth_stats [as 别名]
#.........这里部分代码省略.........
def get_indexing_meta(self, value, index_type):
metric = '{}_{}_{}'.format(self.test_config.name,
index_type.lower(),
self.cluster_spec.name)
title = '{} index (min), {}'.format(index_type,
self.metric_title)
metric_info = self._get_metric_info(title)
return value, metric, metric_info
def calc_compaction_speed(self, time_elapsed, bucket=True):
if bucket:
max_query_params = \
self._get_query_params('max_couch_docs_actual_disk_size')
min_query_params = \
self._get_query_params('min_couch_docs_actual_disk_size')
else:
max_query_params = \
self._get_query_params('max_couch_views_actual_disk_size')
min_query_params = \
self._get_query_params('min_couch_views_actual_disk_size')
max_diff = 0
for bucket in self.test_config.buckets:
db = 'ns_server{}{}'.format(self.cluster_names[0], bucket)
data = self.seriesly[db].query(max_query_params)
disk_size_before = data.values()[0][0]
db = 'ns_server{}{}'.format(self.cluster_names[0], bucket)
data = self.seriesly[db].query(min_query_params)
disk_size_after = data.values()[0][0]
max_diff = max(max_diff, disk_size_before - disk_size_after)
diff = max_diff / 1024 ** 2 / time_elapsed # Mbytes/sec
return round(diff, 1)
def failover_time(self, reporter):
metric = '{}_{}_failover'.format(self.test_config.name,
self.cluster_spec.name)
_split = self.metric_title.split(', ')
title = 'Graceful failover (min), {}, {}'.format(
_split[1][-1] + _split[1][1:-1] + _split[1][0],
', '.join(_split[2:]))
metric_info = self._get_metric_info(title, larger_is_better=False)
rebalance_time = reporter.finish('Failover')
return rebalance_time, metric, metric_info
@property
def calc_network_bandwidth(self):
self.remote = RemoteHelper(self.cluster_spec, self.test_config, verbose=True)
for cluster_name, servers in self.cluster_spec.yield_clusters():
self.in_bytes_transfer += [self.remote.read_bandwidth_stats("to", servers)]
self.out_bytes_transfer += [self.remote.read_bandwidth_stats("from", servers)]
logger.info('in bytes', self.in_bytes_transfer)
logger.info('out bytes', self.out_bytes_transfer)
return OrderedDict((
('in bytes', sum(self.in_bytes_transfer[0].values())),
('out bytes', sum(self.out_bytes_transfer[0].values()))))
@property
def calc_network_throughput(self):
in_bytes_per_sec = []
out_bytes_per_sec = []
for cluster_name, servers in self.cluster_spec.yield_clusters():
cluster = filter(lambda name: name.startswith(cluster_name),
self.cluster_names)[0]
for server in servers:
hostname = server.split(':')[0].replace('.', '')
db = 'net{}{}'.format(cluster, hostname)
data = self.seriesly[db].get_all()
in_bytes_per_sec += [
v['in_bytes_per_sec'] for v in data.values()
]
out_bytes_per_sec += [
v['out_bytes_per_sec'] for v in data.values()
]
# To prevent exception when the values may not be available during code debugging
if not in_bytes_per_sec:
in_bytes_per_sec.append(0)
if not out_bytes_per_sec:
out_bytes_per_sec.append(0)
f = lambda v: format(int(v), ',d')
return OrderedDict((
('min in_bytes per sec', f(min(in_bytes_per_sec))),
('max in_bytes per sec', f(max(in_bytes_per_sec))),
('avg in_bytes per sec', f(np.mean(in_bytes_per_sec))),
('p50 in_bytes per sec', f(np.percentile(in_bytes_per_sec, 50))),
('p95 in_bytes per sec', f(np.percentile(in_bytes_per_sec, 95))),
('p99 in_bytes per sec', f(np.percentile(in_bytes_per_sec, 99))),
('min out_bytes per sec', f(min(out_bytes_per_sec))),
('max out_bytes per sec', f(max(out_bytes_per_sec))),
('avg out_bytes per sec', f(np.mean(out_bytes_per_sec))),
('p50 out_bytes per sec', f(np.percentile(out_bytes_per_sec, 50))),
('p95 out_bytes per sec', f(np.percentile(out_bytes_per_sec, 95))),
('p99 out_bytes per sec', f(np.percentile(out_bytes_per_sec, 99))),
))