From 87b9cc1662dbb3fdda540dabeb85d1cb746f2d83 Mon Sep 17 00:00:00 2001 From: Thomas Phillips Date: Thu, 4 Jan 2018 14:00:17 +1300 Subject: [PATCH 1/2] Add failure rate chart Adds a failure rate chart. Also corrected 95% to 95th --- locust/static/locust.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/locust/static/locust.js b/locust/static/locust.js index ad10fd7221..93fb248703 100644 --- a/locust/static/locust.js +++ b/locust/static/locust.js @@ -43,6 +43,7 @@ $("ul.tabs").tabs("div.panes > div").on("onClick", function(event) { // trigger resizing of charts rpsChart.resize(); responseTimeChart.resize(); + failuresChart.resize(); usersChart.resize(); } }); @@ -119,7 +120,8 @@ $(".stats_label").click(function(event) { // init charts var rpsChart = new LocustLineChart($(".charts-container"), "Total Requests per Second", ["RPS"], "reqs/s"); -var responseTimeChart = new LocustLineChart($(".charts-container"), "Response Times", ["Median Response Time", "95% percentile"], "ms"); +var responseTimeChart = new LocustLineChart($(".charts-container"), "Response Times", ["Median Response Time", "95th percentile"], "ms"); +var failuresChart = new LocustLineChart($(".charts-container"), "Failure rate", ["Failure Rate"], "%"); var usersChart = new LocustLineChart($(".charts-container"), "Number of Users", ["Users"], "users"); function updateStats() { @@ -156,6 +158,7 @@ function updateStats() { // update charts rpsChart.addValue([total.current_rps]); responseTimeChart.addValue([report.current_response_time_percentile_50, report.current_response_time_percentile_95]); + failuresChart.addValue([report.fail_ratio*100]); usersChart.addValue([report.user_count]); } From 25ce5220d0aa4ffb0aaeaa8a8b7f534c26cf928a Mon Sep 17 00:00:00 2001 From: Thomas Phillips Date: Thu, 4 Jan 2018 15:29:56 +1300 Subject: [PATCH 2/2] Restrict failure chart to 0-100% Also nicely adds optional min/max to charts --- locust/static/chart.js | 6 +++++- locust/static/locust.js | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/locust/static/chart.js b/locust/static/chart.js index 03e9ed9d85..7389c06f61 100644 --- a/locust/static/chart.js +++ b/locust/static/chart.js @@ -3,10 +3,12 @@ /** * lines should be an array of line names */ - constructor(container, title, lines, unit) { + constructor(container, title, lines, unit, min, max) { this.container = $(container); this.title = title; this.lines = lines; + this.min = min || null; + this.max = max || null; this.element = $('
').css("width", "100%").appendTo(container); this.data = []; @@ -64,6 +66,8 @@ yAxis: { type: 'value', boundaryGap: [0, '100%'], + min: this.min, + max: this.max, splitLine: { show: false }, diff --git a/locust/static/locust.js b/locust/static/locust.js index 93fb248703..7516f89dc2 100644 --- a/locust/static/locust.js +++ b/locust/static/locust.js @@ -121,7 +121,7 @@ $(".stats_label").click(function(event) { // init charts var rpsChart = new LocustLineChart($(".charts-container"), "Total Requests per Second", ["RPS"], "reqs/s"); var responseTimeChart = new LocustLineChart($(".charts-container"), "Response Times", ["Median Response Time", "95th percentile"], "ms"); -var failuresChart = new LocustLineChart($(".charts-container"), "Failure rate", ["Failure Rate"], "%"); +var failuresChart = new LocustLineChart($(".charts-container"), "Failure rate", ["Failure Rate"], "%", 0, 100); var usersChart = new LocustLineChart($(".charts-container"), "Number of Users", ["Users"], "users"); function updateStats() {