Skip to content

Commit

Permalink
fix(charts): prevent displaying stats before requests are made
Browse files Browse the repository at this point in the history
Stat history would be charted by the client as a stream of consciousness
from the runners until they are stopped.
The client will no longer show unquantified stats (represented by the
number of requests).

Issue: locustio#1852
  • Loading branch information
obradovichv committed Aug 17, 2021
1 parent d7efc71 commit df8bd25
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions locust/static/locust.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,20 +217,28 @@ function updateStats() {
renderTable(report);
renderWorkerTable(report);

if (report.state !== "stopped"){
// get total stats row
var total = report.stats[report.stats.length-1];
// update charts
stats_history["time"].push(new Date().toLocaleTimeString());
stats_history["user_count"].push({"value": report.user_count});
stats_history["current_rps"].push({"value": total.current_rps, "users": report.user_count});
stats_history["current_fail_per_sec"].push({"value": total.current_fail_per_sec, "users": report.user_count});
stats_history["response_time_percentile_50"].push({"value": report.current_response_time_percentile_50, "users": report.user_count});
stats_history["response_time_percentile_95"].push({"value": report.current_response_time_percentile_95, "users": report.user_count});
update_stats_charts()
} else {
if (report.state === "stopped") {
appearStopped();
return;
}

// get total stats row
var total = report.stats[report.stats.length-1];

// ignore stats without requests
if (total.num_requests < 1) {
return;
}

// update charts
stats_history["time"].push(new Date().toLocaleTimeString());
stats_history["user_count"].push({"value": report.user_count});
stats_history["current_rps"].push({"value": total.current_rps, "users": report.user_count});
stats_history["current_fail_per_sec"].push({"value": total.current_fail_per_sec, "users": report.user_count});
stats_history["response_time_percentile_50"].push({"value": report.current_response_time_percentile_50, "users": report.user_count});
stats_history["response_time_percentile_95"].push({"value": report.current_response_time_percentile_95, "users": report.user_count});
update_stats_charts();

} catch(i){
console.debug(i);
}
Expand Down

0 comments on commit df8bd25

Please sign in to comment.