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

Fail ratio calculation for individual requests is incorrect #991

Closed
genericmoniker opened this issue Apr 6, 2019 · 4 comments
Closed

Fail ratio calculation for individual requests is incorrect #991

genericmoniker opened this issue Apr 6, 2019 · 4 comments
Labels

Comments

@genericmoniker
Copy link
Contributor

Description of issue

The fail ratio for each individual request is incorrect, and doesn't match the total fail ratio.

Expected behavior

The fail ratio is correct.

Actual behavior

The fail ratio is incorrect. For example, if 10 out of 10 requests fail, I'd expect the ratio to be 100%, but instead it is 50%.

 Name                                                          # reqs      # fails     Avg     Min     Max  |  Median   req/s               
--------------------------------------------------------------------------------------------------------------------------------------------
 GET /                                                             10   10(50.00%)    2014    2009    2021  |    2000    0.75               
--------------------------------------------------------------------------------------------------------------------------------------------
 Total                                                             10  10(100.00%)                                       0.75               

Environment settings

  • OS: Windows/Linux
  • Python version: 3.6
  • Locust version: 0.11.0

Steps to reproduce (for bug reports)

Create a trivial locustfile.py:

from locust import HttpLocust, TaskSet, task

class UserBehavior(TaskSet):
    @task
    def index(self):
        self.client.get("/")


class WebsiteUser(HttpLocust):
    task_set = UserBehavior

Run it against a host that doesn't have a web server running at all:

locust --host http://localhost --no-web --clients=10 --hatch-rate=2 --run-time=30

All of the "GET /" requests fail, but the stats (as shown above) have the failure rate at 50% rather than 100%.

I think the problem is at stats.py:279:

            return float(self.num_failures) / (self.num_requests + self.num_failures)

It seems like it ought to be:

            return float(self.num_failures) / (self.num_requests)

Maybe at some point self.num_requests was only the count of successful requests?

@cgoldberg
Copy link
Member

Maybe at some point self.num_requests was only the count of successful requests?

good catch.. I believe it was.

Do you want to submit a Pull Request with your fix? (If not, I can take care of it)

@cgoldberg cgoldberg added the bug label Apr 6, 2019
@genericmoniker
Copy link
Contributor Author

Sure, I can make a PR.

genericmoniker added a commit to genericmoniker/locust that referenced this issue Apr 7, 2019
@cgoldberg
Copy link
Member

thanks

@obaranov
Copy link

Hi guys. Do you have any plans to release that fix? From pip we still get v0.11.0, which is affected by that issue?

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

3 participants