本文整理汇总了Python中stats.RequestStats.sum_stats方法的典型用法代码示例。如果您正苦于以下问题:Python RequestStats.sum_stats方法的具体用法?Python RequestStats.sum_stats怎么用?Python RequestStats.sum_stats使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stats.RequestStats
的用法示例。
在下文中一共展示了RequestStats.sum_stats方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ramp_up
# 需要导入模块: from stats import RequestStats [as 别名]
# 或者: from stats.RequestStats import sum_stats [as 别名]
def ramp_up(clients, hatch_stride, boundery_found=False):
while True:
if self.state != STATE_HATCHING:
if self.num_clients >= max_locusts:
print "ramp up stopped due to max locusts limit reached:", max_locusts
client, hatch_stride = ramp_down_help(clients, hatch_stride)
return ramp_down(clients, hatch_stride)
gevent.sleep(calibration_time)
fail_ratio = RequestStats.sum_stats().fail_ratio
if fail_ratio > acceptable_fail:
print "ramp up stopped due to acceptable fail ratio %d%% exceeded with fail ratio %d%%" % (acceptable_fail*100, fail_ratio*100)
client, hatch_stride = ramp_down_help(clients, hatch_stride)
return ramp_down(clients, hatch_stride)
p = current_percentile(percent)
if p >= response_time_limit:
print "ramp up stopped due to percentile response times getting high:", p
client, hatch_stride = ramp_down_help(clients, hatch_stride)
return ramp_down(clients, hatch_stride)
if boundery_found and hatch_stride <= precision:
print "sweet spot found, ramping stopped!"
return
print "ramping up..."
if boundery_found:
hatch_stride = max((hatch_stride/2),precision)
clients += hatch_stride
self.start_hatching(clients, self.hatch_rate)
gevent.sleep(1)
示例2: ramp_down
# 需要导入模块: from stats import RequestStats [as 别名]
# 或者: from stats.RequestStats import sum_stats [as 别名]
def ramp_down(clients, hatch_stride):
while True:
if self.state != STATE_HATCHING:
if self.num_clients < max_locusts:
gevent.sleep(calibration_time)
fail_ratio = RequestStats.sum_stats().fail_ratio
if fail_ratio <= acceptable_fail:
p = current_percentile(percent)
if p <= response_time_limit:
if hatch_stride <= precision:
print "sweet spot found, ramping stopped!"
return
print "ramping up..."
hatch_stride = max((hatch_stride/2),precision)
clients += hatch_stride
self.start_hatching(clients, self.hatch_rate)
return ramp_up(clients, hatch_stride, True)
print "ramping down..."
hatch_stride = max((hatch_stride/2),precision)
clients -= hatch_stride
if clients > 0:
self.start_hatching(clients, self.hatch_rate)
else:
print "WARNING: no responses met the ramping thresholds, check your ramp configuration, locustfile and \"--host\" address"
print "ramping stopped!"
return
gevent.sleep(1)
示例3: ramp_up
# 需要导入模块: from stats import RequestStats [as 别名]
# 或者: from stats.RequestStats import sum_stats [as 别名]
def ramp_up(clients, hatch_stride, boundery_found=False):
while True:
if locust_runner.state != STATE_HATCHING:
if locust_runner.num_clients >= max_locusts:
logger.info("Ramp up halted; Max locusts limit reached: %d" % max_locusts)
return ramp_down(clients, hatch_stride)
gevent.sleep(calibration_time)
fail_ratio = RequestStats.sum_stats().fail_ratio
if fail_ratio > acceptable_fail:
logger.info("Ramp up halted; Acceptable fail ratio %d%% exceeded with fail ratio %d%%" % (acceptable_fail*100, fail_ratio*100))
return ramp_down(clients, hatch_stride)
p = current_percentile(percent)
if p >= response_time_limit:
logger.info("Ramp up halted; Percentile response times getting high: %d" % p)
return ramp_down(clients, hatch_stride)
if boundery_found and hatch_stride <= precision:
logger.info("Sweet spot found! Ramping stopped at %i locusts" % (locust_runner.num_clients))
return remove_listeners()
logger.info("Ramping up...")
if boundery_found:
hatch_stride = max((hatch_stride/2),precision)
clients += hatch_stride
locust_runner.start_hatching(clients, locust_runner.hatch_rate)
gevent.sleep(1)
示例4: ramp_down
# 需要导入模块: from stats import RequestStats [as 别名]
# 或者: from stats.RequestStats import sum_stats [as 别名]
def ramp_down(clients, hatch_stride):
while True:
if locust_runner.state != STATE_HATCHING:
if locust_runner.num_clients < max_locusts:
gevent.sleep(calibration_time)
fail_ratio = RequestStats.sum_stats().fail_ratio
if fail_ratio <= acceptable_fail:
p = current_percentile(percent)
if p <= response_time_limit:
if hatch_stride <= precision:
logger.info("Sweet spot found! Ramping stopped at %i locusts" % (locust_runner.num_clients))
return remove_listeners()
logger.info("Ramping up...")
hatch_stride = max((hatch_stride/2),precision)
clients += hatch_stride
locust_runner.start_hatching(clients, locust_runner.hatch_rate)
return ramp_up(clients, hatch_stride, True)
logger.info("Ramping down...")
hatch_stride = max((hatch_stride/2),precision)
clients -= hatch_stride
if clients > 0:
locust_runner.start_hatching(clients, locust_runner.hatch_rate)
else:
logger.warning("No responses met the ramping thresholds, check your ramp configuration, locustfile and \"--host\" address")
logger.info("RAMING STOPPED")
return remove_listeners()
gevent.sleep(1)
示例5: stats_csv
# 需要导入模块: from stats import RequestStats [as 别名]
# 或者: from stats.RequestStats import sum_stats [as 别名]
def stats_csv(self):
rows = [
",".join([
'"Method"',
'"Name"',
'"# requests"',
'"# failures"',
'"Median response time"',
'"Average response time"',
'"Min response time"',
'"Max response time"',
'"Average Content Size"',
'"Reqests/s"',
])
]
for s in chain(_sort_stats(self.request_stats), [RequestStats.sum_stats("Total", full_request_history=True)]):
rows.append('"%s","%s",%i,%i,%i,%i,%i,%i,%i,%.2f' % (
s.method,
s.name,
s.num_reqs,
s.num_failures,
s.median_response_time,
s.avg_response_time,
s.min_response_time or 0,
s.max_response_time,
s.avg_content_length,
s.total_rps,
))
return "\n".join(rows)
示例6: on_request_success_ramping
# 需要导入模块: from stats import RequestStats [as 别名]
# 或者: from stats.RequestStats import sum_stats [as 别名]
def on_request_success_ramping(_, _1, response_time, _2):
if is_distributed:
response_times.append(response_time)
else:
response_times.append(response_time)
# remove from the queue
rps = RequestStats.sum_stats().current_rps
if len(response_times) > rps*PERCENTILE_TIME_WINDOW:
for i in xrange(len(response_times) - int(math.ceil(rps*PERCENTILE_TIME_WINDOW))):
response_times.popleft()
示例7: distribution_stats_csv
# 需要导入模块: from stats import RequestStats [as 别名]
# 或者: from stats.RequestStats import sum_stats [as 别名]
def distribution_stats_csv(self):
rows = [",".join((
'"Name"',
'"# requests"',
'"50%"',
'"66%"',
'"75%"',
'"80%"',
'"90%"',
'"95%"',
'"98%"',
'"99%"',
'"100%"',
))]
for s in chain(_sort_stats(self.request_stats), [RequestStats.sum_stats("Total", full_request_history=True)]):
if s.num_reqs:
rows.append(s.percentile(tpl='"%s",%i,%i,%i,%i,%i,%i,%i,%i,%i,%i'))
else:
rows.append('"%s",0,"N/A","N/A","N/A","N/A","N/A","N/A","N/A","N/A","N/A"' % s.name)
return "\n".join(rows)