From b330e7693f713e3721455cb6147c157bd684dd50 Mon Sep 17 00:00:00 2001 From: Andrew Baldwin Date: Thu, 18 Jul 2024 07:12:29 -0400 Subject: [PATCH 1/2] Replace total avg response time with 50 percentile --- locust/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/locust/main.py b/locust/main.py index 317db376c6..056b5208a8 100644 --- a/locust/main.py +++ b/locust/main.py @@ -38,7 +38,7 @@ try: # import locust_plugins if it is installed, to allow it to register custom arguments etc - import locust_plugins # pyright: ignore[reportMissingImports] + import locust_cloud # pyright: ignore[reportMissingImports] except ModuleNotFoundError: pass From 76e5d6833c57ec211fd5ea33a823654b00929830 Mon Sep 17 00:00:00 2001 From: Andrew Baldwin Date: Wed, 24 Jul 2024 12:52:57 -0400 Subject: [PATCH 2/2] Fix html report stats table --- locust/main.py | 2 +- locust/stats.py | 3 +++ .../src/components/StatsTable/StatsTable.tsx | 10 ++++++++-- locust/webui/src/pages/HtmlReport.tsx | 15 ++++++++++++++- 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/locust/main.py b/locust/main.py index 056b5208a8..317db376c6 100644 --- a/locust/main.py +++ b/locust/main.py @@ -38,7 +38,7 @@ try: # import locust_plugins if it is installed, to allow it to register custom arguments etc - import locust_cloud # pyright: ignore[reportMissingImports] + import locust_plugins # pyright: ignore[reportMissingImports] except ModuleNotFoundError: pass diff --git a/locust/stats.py b/locust/stats.py index a18c06297f..45b06d0f76 100644 --- a/locust/stats.py +++ b/locust/stats.py @@ -679,7 +679,10 @@ def to_dict(self, escape_string_values=False): "max_response_time": proper_round(self.max_response_time), "current_rps": self.current_rps, "current_fail_per_sec": self.current_fail_per_sec, + "avg_response_time": self.avg_response_time, "median_response_time": self.median_response_time, + "total_rps": self.total_rps, + "total_fail_per_sec": self.total_fail_per_sec, **response_time_percentiles, "avg_content_length": self.avg_content_length, } diff --git a/locust/webui/src/components/StatsTable/StatsTable.tsx b/locust/webui/src/components/StatsTable/StatsTable.tsx index e6c1e04012..d542a1a213 100644 --- a/locust/webui/src/components/StatsTable/StatsTable.tsx +++ b/locust/webui/src/components/StatsTable/StatsTable.tsx @@ -5,6 +5,7 @@ import ViewColumnSelector from 'components/ViewColumnSelector/ViewColumnSelector import { swarmTemplateArgs } from 'constants/swarm'; import useSelectViewColumns from 'hooks/useSelectViewColumns'; import { IRootState } from 'redux/store'; +import { ITableStructure } from 'types/table.types'; import { ISwarmStat } from 'types/ui.types'; const percentilesToStatisticsRows = swarmTemplateArgs.percentilesToStatistics @@ -14,7 +15,7 @@ const percentilesToStatisticsRows = swarmTemplateArgs.percentilesToStatistics })) : []; -const tableStructure = [ +export const baseTableStructure = [ { key: 'method', title: 'Type' }, { key: 'name', title: 'Name' }, { key: 'numRequests', title: '# Requests' }, @@ -29,7 +30,12 @@ const tableStructure = [ { key: 'currentFailPerSec', title: 'Current Failures/s', round: 2 }, ]; -export function StatsTable({ stats }: { stats: ISwarmStat[] }) { +interface IStatsTable { + stats: ISwarmStat[]; + tableStructure?: ITableStructure[]; +} + +export function StatsTable({ stats, tableStructure = baseTableStructure }: IStatsTable) { const { selectedColumns, addColumn, removeColumn, filteredStructure } = useSelectViewColumns(tableStructure); diff --git a/locust/webui/src/pages/HtmlReport.tsx b/locust/webui/src/pages/HtmlReport.tsx index efca751d58..32394cf533 100644 --- a/locust/webui/src/pages/HtmlReport.tsx +++ b/locust/webui/src/pages/HtmlReport.tsx @@ -15,6 +15,19 @@ import { formatLocaleString } from 'utils/date'; const theme = createTheme(window.theme || INITIAL_THEME); +const statsReportTableStructure = [ + { key: 'method', title: 'Type' }, + { key: 'name', title: 'Name' }, + { key: 'numRequests', title: '# Requests' }, + { key: 'numFailures', title: '# Fails' }, + { key: 'avgResponseTime', title: 'Average (ms)', round: 2 }, + { key: 'minResponseTime', title: 'Min (ms)' }, + { key: 'maxResponseTime', title: 'Max (ms)' }, + { key: 'avgContentLength', title: 'Average size (bytes)', round: 2 }, + { key: 'totalRps', title: 'RPS', round: 2 }, + { key: 'totalFailPerSec', title: 'Failures/s', round: 2 }, +]; + export default function HtmlReport({ locustfile, showDownloadLink, @@ -72,7 +85,7 @@ export default function HtmlReport({ Request Statistics - + {!!responseTimeStatistics.length && (