Compute Response Time in Postman
Sometimes, as a test engineer, you need to perform a non-function testing
When developers start to speed up an API the QA department usually get two types of tasks:
- Сheck that handlers work the same way as they worked before (that could be tested by comparison of responses);
- Check that handlers start work faster.
Postman allows to test the response time, but one check is often not enough. For complex testing of response time we need to measure:
- Average response time, based on a large number of requests;
- Maximum (peak) response time to find out the extremes.
To perform such testing we should:
- Run required request multiple times through Postman collection runner;
- Save each of response time into variable;
- Calculate average and maximum timings.
First of all, we need to create a variable without value.
Then, write a few lines of code in the Tests tab of the request (I took for example one handler of The COVID Tracking Project API). For convenience, I have output the calculated data into the test name.
The only edge case is the first or single request, which should be taken into consideration and properly handled.
Now, we should clear the variable’s value (otherwise it will affect our subsequent results) and run the collection with a significant amount of iterations.
On the last request we will get average and maximum response timings.
When we perform the same test (run this collection with the same number of iterations) for two handlers: the benchmark and the new one, we can compare our metrics.