Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HttpClient: Fixed LatencyMeanMs not calculating properly #677

Merged
merged 2 commits into from
Jan 4, 2024

Conversation

keithmifsud17
Copy link
Contributor

LatencyMeanMs is not taking into consideration the parallelism nature of the load test.

The calculation is currently done by taking the whole time it took to run the test and divide it by the number of requests which implies that the requests were done sequentially

@@ -375,7 +375,7 @@ IEnumerable<Task> CreateTasks()
Started = startTime.ToLocalTime(),
ThroughputBps = workerTasks.Select(x => x.Result.ThroughputBps).Sum(),
LatencyMaxMs = Math.Round(workerTasks.Select(x => x.Result.LatencyMaxMs).Max(), 3),
LatencyMeanMs = workerTasks.Select(x => x.Result.TotalRequests).Sum() == 0 ? 0 : Math.Round((stopTime - startTime).TotalMilliseconds / workerTasks.Select(x => x.Result.TotalRequests).Sum(), 3),
LatencyMeanMs = Math.Round(workerTasks.Select(x => x.Result.LatencyMeanMs).Average(), 3),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is assuming that each worker sends the same amount of requests, but we can do that. Meaning that if a worker was sending a single request that is 1ms, and another worker was sending 1000 requests of 1s avg, then it would result in an average of 500ms while it closer to 1s. Whatever, this is closer to reality now.

The only correct option would be to store the TotalLatency and TotalRequests per worker and then do the mean of all these.

Copy link
Contributor Author

@keithmifsud17 keithmifsud17 Dec 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah yes, you are correct. In reality we want the sum of TotalLatency of all workers divided by the sum of TotalRequests of all workers.

Change has been done :)

@sebastienros sebastienros merged commit 63b1341 into dotnet:main Jan 4, 2024
4 checks passed
@keithmifsud17 keithmifsud17 deleted the fix/HttpClientLatencyMean branch January 4, 2024 08:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants