Skip to content

Commit

Permalink
Fix grammatical error in statistic reporting
Browse files Browse the repository at this point in the history
Changed all `occurences` to `occurrences`
  • Loading branch information
MaxVanDeursen authored and cgoldberg committed Jun 10, 2019
1 parent 84ffbae commit f0a5f89
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 21 deletions.
6 changes: 3 additions & 3 deletions locust/runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,18 +97,18 @@ def spawn_locusts(self, spawn_count=None, stop_timeout=None, wait=False):
self.num_clients += spawn_count

logger.info("Hatching and swarming %i clients at the rate %g clients/s..." % (spawn_count, self.hatch_rate))
occurence_count = dict([(l.__name__, 0) for l in self.locust_classes])
occurrence_count = dict([(l.__name__, 0) for l in self.locust_classes])

def hatch():
sleep_time = 1.0 / self.hatch_rate
while True:
if not bucket:
logger.info("All locusts hatched: %s" % ", ".join(["%s: %d" % (name, count) for name, count in six.iteritems(occurence_count)]))
logger.info("All locusts hatched: %s" % ", ".join(["%s: %d" % (name, count) for name, count in six.iteritems(occurrence_count)]))
events.hatch_complete.fire(user_count=self.num_clients)
return

locust = bucket.pop(random.randint(0, len(bucket)-1))
occurence_count[locust.__name__] += 1
occurrence_count[locust.__name__] += 1
def start_locust(_):
try:
locust().run(runner=self)
Expand Down
4 changes: 2 additions & 2 deletions locust/static/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -329,15 +329,15 @@ a:hover {
text-align: left;
}

#exceptions th.exception_occurences {
#exceptions th.exception_occurrences {
width: 110px;
text-align: center;
}
#exceptions th.exception_traceback {
text-align: left;
}

#exceptions td.occurences {
#exceptions td.occurrences {
text-align: center;
}
#exceptions td.traceback {
Expand Down
24 changes: 12 additions & 12 deletions locust/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def log_error(self, method, name, error):
if not entry:
entry = StatsError(method, name, error)
self.errors[key] = entry
entry.occured()
entry.occurred()

def get(self, name, method):
"""
Expand Down Expand Up @@ -485,11 +485,11 @@ def _cache_response_times(self, t):


class StatsError(object):
def __init__(self, method, name, error, occurences=0):
def __init__(self, method, name, error, occurrences=0):
self.method = method
self.name = name
self.error = error
self.occurences = occurences
self.occurrences = occurrences

@classmethod
def parse_error(cls, error):
Expand All @@ -510,8 +510,8 @@ def create_key(cls, method, name, error):
key = "%s.%s.%r" % (method, name, StatsError.parse_error(error))
return hashlib.md5(key.encode('utf-8')).hexdigest()

def occured(self):
self.occurences += 1
def occurred(self):
self.occurrences += 1

def to_name(self):
return "%s %s: %r" % (self.method,
Expand All @@ -522,7 +522,7 @@ def to_dict(self):
"method": self.method,
"name": self.name,
"error": StatsError.parse_error(self.error),
"occurences": self.occurences
"occurrences": self.occurrences
}

@classmethod
Expand All @@ -531,7 +531,7 @@ def from_dict(cls, data):
data["method"],
data["name"],
data["error"],
data["occurences"]
data["occurrences"]
)


Expand Down Expand Up @@ -580,7 +580,7 @@ def on_slave_report(client_id, data):
if error_key not in global_stats.errors:
global_stats.errors[error_key] = StatsError.from_dict(error)
else:
global_stats.errors[error_key].occurences += error["occurences"]
global_stats.errors[error_key].occurrences += error["occurrences"]

# save the old last_request_timestamp, to see if we should store a new copy
# of the response times in the response times cache
Expand Down Expand Up @@ -647,7 +647,7 @@ def print_error_report():
console_logger.info(" %-18s %-100s" % ("# occurrences", "Error"))
console_logger.info("-" * (80 + STATS_NAME_WIDTH))
for error in six.itervalues(global_stats.errors):
console_logger.info(" %-18i %-100s" % (error.occurences, error.to_name()))
console_logger.info(" %-18i %-100s" % (error.occurrences, error.to_name()))
console_logger.info("-" * (80 + STATS_NAME_WIDTH))
console_logger.info("")

Expand Down Expand Up @@ -745,7 +745,7 @@ def failures_csv():
'"Method"',
'"Name"',
'"Error"',
'"Occurences"',
'"Occurrences"',
))
]

Expand All @@ -754,6 +754,6 @@ def failures_csv():
s.method,
s.name,
s.error,
s.occurences,
s.occurrences,
))
return "\n".join(rows)
return "\n".join(rows)
6 changes: 3 additions & 3 deletions locust/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ <h2>Change the locust count</h2>
<div style="display:none;">
<table id="exceptions" class="stats">
<thead>
<th class="exception_occurences stats_label" data-sortkey="1"># occurences</th>
<th class="exception_occurrences stats_label" data-sortkey="1"># occurrences</th>
<th class="exception_traceback stats_label" data-sortkey="0">Traceback</th>
</thead>
<tbody>
Expand Down Expand Up @@ -235,7 +235,7 @@ <h2>Version <a href="https://github.com/locustio/locust/releases/tag/{{version}}
<script type="text/x-jqote-template" id="errors-template">
<![CDATA[
<tr class="<%=(alternate ? "dark" : "")%>">
<td><%= this.occurences %></td>
<td><%= this.occurrences %></td>
<td><%= this.method %></td>
<td><%= this.name %></td>
<td><%= function(e) { return e.replace("<", "&lt;"); }(this.error) %></td>
Expand All @@ -246,7 +246,7 @@ <h2>Version <a href="https://github.com/locustio/locust/releases/tag/{{version}}
<script type="text/x-jqote-template" id="exceptions-template">
<![CDATA[
<tr class="<%=(alternate ? "dark" : "")%>">
<td class="occurences"><%= this.count %></td>
<td class="occurrences"><%= this.count %></td>
<td class="traceback" title="Occured on: <%= this.nodes %>"><%= function(e) { return e.replace("<", "&lt;"); }(this.traceback) %>
<%= function(e) { return e.replace("<", "&lt;"); }(this.msg) %></td>
</tr>
Expand Down
2 changes: 1 addition & 1 deletion locust/test/test_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def test_error_grouping(self):
self.stats.log_error("GET", "/some-path", Exception("Exception!"))

self.assertEqual(1, len(self.stats.errors))
self.assertEqual(2, list(self.stats.errors.values())[0].occurences)
self.assertEqual(2, list(self.stats.errors.values())[0].occurrences)

self.stats.log_error("GET", "/some-path", Exception("Another exception!"))
self.stats.log_error("GET", "/some-path", Exception("Another exception!"))
Expand Down

2 comments on commit f0a5f89

@myzhan
Copy link
Contributor

@myzhan myzhan commented on f0a5f89 Jun 14, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, this change is not compatible with other slave runner like boomer.

@myzhan
Copy link
Contributor

@myzhan myzhan commented on f0a5f89 Jun 14, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trying to keep compatible with previous versions of locust by keeping the typo as key.

myzhan/boomer@e48644b#diff-ac30af7ac3674a84335ddfddbe2d4d03R298

Please # to comment.