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

HttpSession should use response.elapsed for response time #930

Closed
joaonc opened this issue Dec 11, 2018 · 5 comments
Closed

HttpSession should use response.elapsed for response time #930

joaonc opened this issue Dec 11, 2018 · 5 comments
Labels

Comments

@joaonc
Copy link

joaonc commented Dec 11, 2018

As we can see here, the HttpSession class is calculating the response time on its own, when the response object already has that information in the elapsed property:

http://docs.python-requests.org/en/master/api/#requests.Response.elapsed

HttpSession should use that elapse property instead of calculating its own.

For a quick, backwards compatible, change, maybe something like:
request_meta["response_time"] = response.elapsed

I think this would give us more accurate representations of the actual response time. Per documentation:

[...] It is therefore unaffected by consuming the response content or the value of the stream keyword argument.

@SpencerPinegar
Copy link

I like this fix for all http requests, my one worry is that other clients might assume there response times are always accurate (as we are assuming this fix would be for http requests) when something might be slowing down there response times - but this could be fixed with some good documentation.

@SpencerPinegar
Copy link

Hey Joaonc, I spoke with @cgoldberg Suggested "try to get timing from response.elapsed and also set a timer... then catch the exception if response.elapsed doesn't exist, and use the timer. That way you would get better timing for the HTTP client, and still use the existing behavior when using others"

This would make http request response times accurate (the most common use case) while still allowing other non-http clients to estimate a response time. This would need to be added in so locust can work for all types of clients, not just http clients.

@heyman
Copy link
Member

heyman commented Oct 22, 2019

I suspect that response.elapsed doesn't include the total for all requests when the requests client automatically follows redirects (by default)? I guess we could loop over all the responses and add all elapsed together.

@cyberw
Copy link
Collaborator

cyberw commented Nov 18, 2019

Closing as wontfix, the new geventhttpclient lib used by FastHttpLocust doesnt measure response times internally, so we're stuck having to calculate it. And FastHttpLocust is "the Future" imo.

@cyberw cyberw closed this as completed Nov 18, 2019
@cyberw cyberw added the wontfix label Nov 18, 2019
@roarscarch
Copy link

Hi, I ran test-cases and the average response time I got from Locust was more than that what I got from the actual response time.
image
image

Why is that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants