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

Calculate requests per second from json report #1194

Closed
Paxa opened this issue Oct 8, 2019 · 1 comment
Closed

Calculate requests per second from json report #1194

Paxa opened this issue Oct 8, 2019 · 1 comment
Labels

Comments

@Paxa
Copy link

Paxa commented Oct 8, 2019

I would like to get req/sec value from json report, I try to run script for 10 seconds and check difference between first time and last time in json report, I get 7847 ms, and I got very different result then terminal output

http_reqs..................: 38            3.799899/s

From my script

Total requests: 38
exec time: 7847 ms
req/sec: 4.842615012106537

Then I try to save start time and end time in my benchmark:

import { Gauge } from "k6/metrics";
var startCounter = new Gauge("start_counter");
var endCounter = new Gauge("end_counter");

export default function() {
  startCounter.add(Date.now());
  // my bench code
  endCounter.add(Date.now());
};

And I got better results:

exec time: 9890
req/sec: 3.8422649140546006 <-- almost good

Is there a better way to do it?

@cuonglm cuonglm added evaluation needed proposal needs to be validated or tested before fully implementing it in k6 question labels Oct 8, 2019
@na--
Copy link
Member

na-- commented Oct 9, 2019

@Paxa, I'm not completely sure what you're trying to do, can you explain in some more detail?

Regarding the metric timestamps when you output them to a JSON file, they represent the times when the response was received and processed. So, even if you make an HTTP request at t=0, if it takes 2 seconds to receive its response, you're going to see t=2s as the JSON metric timestamp. So, to calculate the req/s, you probably just need to divide the number of request metrics in that JSON file by the duration you specified for the test run.

If you just need the requests per second in a machine readable format, you might want to follow #1168. This PR would allow the exporting of all of the metrics you see in the end-of-test summary as a JSON file, so you don't need to process each individual metric to get the summary.

@na-- na-- removed the evaluation needed proposal needs to be validated or tested before fully implementing it in k6 label Oct 9, 2019
@Paxa Paxa closed this as completed Oct 18, 2019
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