Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stats refactoring #74

Merged
merged 4 commits into from
May 20, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions locust/runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import events
from locust.stats import print_percentile_stats
from stats import RequestStats, print_stats
from stats import RequestStats, print_stats, global_stats
from exception import RescheduleTaskImmediately

from rpc import rpc, Message
Expand All @@ -38,21 +38,22 @@ def __init__(self, locust_classes, hatch_rate, num_clients, num_requests=None, h
self.state = STATE_INIT
self.hatching_greenlet = None
self.exceptions = {}
self.stats = global_stats

# register listener that resets stats when hatching is complete
def on_hatch_complete(count):
self.state = STATE_RUNNING
logger.info("Resetting stats\n")
RequestStats.reset_all()
self.stats.reset_all()
events.hatch_complete += on_hatch_complete

@property
def request_stats(self):
return RequestStats.requests
return self.stats.entries

@property
def errors(self):
return RequestStats.errors
return self.stats.errors

@property
def user_count(self):
Expand Down Expand Up @@ -86,7 +87,7 @@ def spawn_locusts(self, spawn_count=None, stop_timeout=None, wait=False):
spawn_count = self.num_clients

if self.num_requests is not None:
RequestStats.global_max_requests = self.num_requests
self.stats.max_requests = self.num_requests

bucket = self.weight_locusts(spawn_count, stop_timeout)
spawn_count = len(bucket)
Expand Down Expand Up @@ -145,8 +146,8 @@ def kill_locusts(self, kill_count):

def start_hatching(self, locust_count=None, hatch_rate=None, wait=False):
if self.state != STATE_RUNNING and self.state != STATE_HATCHING:
RequestStats.clear_all()
RequestStats.global_start_time = time()
self.stats.clear_all()
self.stats.start_time = time()
self.exceptions = {}

# Dynamically changing the locust count
Expand Down Expand Up @@ -268,14 +269,14 @@ def start_hatching(self, locust_count, hatch_rate):
return

if self.state != STATE_RUNNING and self.state != STATE_HATCHING:
RequestStats.clear_all()
self.stats.clear_all()
self.exceptions = {}

for client in self.clients.itervalues():
data = {"hatch_rate":slave_hatch_rate, "num_clients":slave_num_clients, "num_requests": self.num_requests, "host":self.host, "stop_timeout":None}
self.server.send(Message("hatch", data, None))

RequestStats.global_start_time = time()
self.stats.start_time = time()
self.state = STATE_HATCHING

def stop(self):
Expand Down
Loading