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

Empty stats on get aggregated stats #232

Closed
drgarcia1986 opened this issue Jan 20, 2015 · 2 comments
Closed

Empty stats on get aggregated stats #232

drgarcia1986 opened this issue Jan 20, 2015 · 2 comments

Comments

@drgarcia1986
Copy link

I'm trying to save the test results to a file, but the result is saved with empty values, am I doing something wrong? I am using the following event:

def on_quitting():
    requests_result = RequestStats().aggregated_stats()
    with open('load_tests.json', 'w') as f:
        f.write(str(requests_result.serialize()))


events.quitting += on_quitting

And I'm execultando the locust as follows:

locust -f locust_script.py --no-web -c 10 -r 5 -n 50 -H http://localhost:5000 --only-summary

The console is being presented the following result:

 Name                                                          # reqs      # fails     Avg     Min     Max  |  Median   req/s
--------------------------------------------------------------------------------------------------------------------------------------------
 GET /dh/[int]                                                     23     0(0.00%)       7       6      10  |       8    2.38
 GET /dm/[int]                                                     27     0(0.00%)       7       4       9  |       8    2.38
--------------------------------------------------------------------------------------------------------------------------------------------
 Total                                                             50     0(0.00%)                                       4.75

Percentage of the requests completed within given times
 Name                                                           # reqs    50%    66%    75%    80%    90%    95%    98%    99%   100%
--------------------------------------------------------------------------------------------------------------------------------------------
 GET /dh/[int]                                                      23      8      8      8      8      8      9     10     10     10
 GET /dm/[int]                                                      27      8      8      8      8      8      8      9      9      9
--------------------------------------------------------------------------------------------------------------------------------------------

but in the file:

{'num_reqs_per_sec': {}, 'response_times': {}, 'start_time': 1421713788.737998, 'min_response_time': None, 'num_failures': 0, 'num_requests': 0, 'name': 'Total', 'total_response_time': 0, 'max_response_time': 0, 'total_content_length': 0, 'last_request_timestamp': 1421713788, 'method': None}
@drgarcia1986
Copy link
Author

Solution:

from locust.stats import global_stats


def on_quitting():
    requests_result = global_stats.aggregated_stats()
    with open('load_tests.json', 'w') as f:
        f.write(str(requests_result.serialize()))

@anishlr
Copy link

anishlr commented Sep 14, 2015

I have this same issue now, but I think my issue is to do with the way I'm quitting my Locusts.

How did you quit the Locust that you ran from the console?

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

No branches or pull requests

2 participants