From 406ed5601327112a131bf38d89779c104219a2e9 Mon Sep 17 00:00:00 2001 From: Axel Mendoza Date: Tue, 19 Jan 2021 18:08:20 -0500 Subject: [PATCH 1/3] integrate chart persistence with new tests stats --- locust/static/locust.js | 67 +++++++++++++++++++++++------------------ 1 file changed, 37 insertions(+), 30 deletions(-) diff --git a/locust/static/locust.js b/locust/static/locust.js index 7b340772c2..7dd309d1e8 100644 --- a/locust/static/locust.js +++ b/locust/static/locust.js @@ -174,38 +174,41 @@ $("#workers .stats_label").click(function(event) { renderWorkerTable(window.report); }); +function update_stats_charts(){ + if(stats_history["time"].length > 0){ + rpsChart.chart.setOption({ + xAxis: {data: stats_history["time"]}, + series: [ + {data: stats_history["current_rps"]}, + {data: stats_history["current_fail_per_sec"]}, + ] + }); + + responseTimeChart.chart.setOption({ + xAxis: {data: stats_history["time"]}, + series: [ + {data: stats_history["response_time_percentile_50"]}, + {data: stats_history["response_time_percentile_95"]}, + ] + }); + + usersChart.chart.setOption({ + xAxis: { + data: stats_history["time"] + }, + series: [ + {data: stats_history["user_count"]}, + ] + }); + } +} + // init charts var rpsChart = new LocustLineChart($(".charts-container"), "Total Requests per Second", ["RPS", "Failures/s"], "reqs/s", ['#00ca5a', '#ff6d6d']); var responseTimeChart = new LocustLineChart($(".charts-container"), "Response Times (ms)", ["Median Response Time", "95% percentile"], "ms"); var usersChart = new LocustLineChart($(".charts-container"), "Number of Users", ["Users"], "users"); charts.push(rpsChart, responseTimeChart, usersChart); - -if(stats_history["time"].length > 0){ - rpsChart.chart.setOption({ - xAxis: {data: stats_history["time"]}, - series: [ - {data: stats_history["current_rps"]}, - {data: stats_history["current_fail_per_sec"]}, - ] - }); - - responseTimeChart.chart.setOption({ - xAxis: {data: stats_history["time"]}, - series: [ - {data: stats_history["response_time_percentile_50"]}, - {data: stats_history["response_time_percentile_95"]}, - ] - }); - - usersChart.chart.setOption({ - xAxis: { - data: stats_history["time"] - }, - series: [ - {data: stats_history["user_count"]}, - ] - }); -} +update_stats_charts() function updateStats() { $.get('./stats/requests', function (report) { @@ -218,9 +221,13 @@ function updateStats() { // get total stats row var total = report.stats[report.stats.length-1]; // update charts - rpsChart.addValue([total.current_rps, total.current_fail_per_sec], report.user_count); - responseTimeChart.addValue([report.current_response_time_percentile_50, report.current_response_time_percentile_95], report.user_count); - usersChart.addValue([report.user_count]); + stats_history["time"].push(report.user_count); + stats_history["user_count"].push(report.user_count); + stats_history["current_rps"].push(total.current_rps); + stats_history["current_fail_per_sec"].push(total.current_fail_per_sec); + stats_history["response_time_percentile_50"].push(report.current_response_time_percentile_50); + stats_history["response_time_percentile_95"].push(report.current_response_time_percentile_95); + update_stats_charts() } else { appearStopped(); } From 18d7314b5d5a76a9495d21f19c88e5936b424646 Mon Sep 17 00:00:00 2001 From: Axel Mendoza Date: Tue, 19 Jan 2021 19:21:27 -0500 Subject: [PATCH 2/3] fix time value --- locust/static/locust.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/locust/static/locust.js b/locust/static/locust.js index 7dd309d1e8..c455ccc26d 100644 --- a/locust/static/locust.js +++ b/locust/static/locust.js @@ -221,7 +221,7 @@ function updateStats() { // get total stats row var total = report.stats[report.stats.length-1]; // update charts - stats_history["time"].push(report.user_count); + stats_history["time"].push(new Date().toLocaleTimeString()); stats_history["user_count"].push(report.user_count); stats_history["current_rps"].push(total.current_rps); stats_history["current_fail_per_sec"].push(total.current_fail_per_sec); From 925005c80a70e0590d5d2b0c1e7df36a81c9f539 Mon Sep 17 00:00:00 2001 From: Axel Mendoza Date: Tue, 19 Jan 2021 20:00:14 -0500 Subject: [PATCH 3/3] prevent to stop looking for data --- locust/static/locust.js | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/locust/static/locust.js b/locust/static/locust.js index c455ccc26d..c1f338f41f 100644 --- a/locust/static/locust.js +++ b/locust/static/locust.js @@ -213,25 +213,28 @@ update_stats_charts() function updateStats() { $.get('./stats/requests', function (report) { window.report = report; - - 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(report.user_count); - stats_history["current_rps"].push(total.current_rps); - stats_history["current_fail_per_sec"].push(total.current_fail_per_sec); - stats_history["response_time_percentile_50"].push(report.current_response_time_percentile_50); - stats_history["response_time_percentile_95"].push(report.current_response_time_percentile_95); - update_stats_charts() - } else { - appearStopped(); + try{ + 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(report.user_count); + stats_history["current_rps"].push(total.current_rps); + stats_history["current_fail_per_sec"].push(total.current_fail_per_sec); + stats_history["response_time_percentile_50"].push(report.current_response_time_percentile_50); + stats_history["response_time_percentile_95"].push(report.current_response_time_percentile_95); + update_stats_charts() + } else { + appearStopped(); + } + } catch(i){ + console.debug(i); } - + }).always(function() { setTimeout(updateStats, 2000); }); }