From df8bd25689c9f482ba6adc161a73257556cf18e7 Mon Sep 17 00:00:00 2001 From: obradovichv <53901450+obradovichv@users.noreply.github.com> Date: Tue, 17 Aug 2021 17:28:15 +0000 Subject: [PATCH] fix(charts): prevent displaying stats before requests are made 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: #1852 --- locust/static/locust.js | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/locust/static/locust.js b/locust/static/locust.js index 867b476757..efca2c6933 100644 --- a/locust/static/locust.js +++ b/locust/static/locust.js @@ -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); }