Search code examples
javascriptperformanceperformance-testingpostman

Response times from PostMan scripts


Is there a simple way to capture the Response times for the requests and responses in a PostMan script?

I am trying to do the following by creating a Collection and then in the Tests, writing the following script to capture and put the value in an Environment variable:

postman.setEnvironmentVariable("MyURLRequest", (responseTime));

This provides me the value in the Environment variable, but I need to specifically go there everytime to check the time.

The other way I have tried is to use the 'Runner' on the collection and get the response times from the "totalRequestTime" value in the exported results. But as I am running ~50 requests, it becomes hard to capture the same for each individual request.

Has anyone tried this earlier and been able to get a better way to capture and export a response time value for each request sent out?


Solution

  • You could use the built-in pm.response.responseTime function to get the times.

    Add it to a console.log(pm.response.responseTime) in a test, to try it out or assign this to an env/global variable.

    You could even (it's a little bit over kill though) do this:

    Response Times

    If you didn't want it in each test, this could be added to the collection. On the latest version, press edit on the collection to see the options.