Response time benchmarking helps us check how fast a website or API responds. It shows if the system is quick enough for users.
0
0
Response time benchmarking in Postman
Introduction
When you want to see if a website loads fast enough for visitors.
When testing an API to ensure it responds within acceptable time limits.
Before launching a new feature to check it does not slow down the system.
After making changes to the server to confirm performance is stable.
To compare response times between different versions of an API.
Syntax
Postman
pm.test("Response time is less than 200ms", function () { pm.expect(pm.response.responseTime).to.be.below(200); });
pm.response.responseTime gives the response time in milliseconds.
Use pm.expect() to create an assertion that checks the response time.
Examples
This test checks if the response time is less than 500 milliseconds.
Postman
pm.test("Response time is under 500ms", function () { pm.expect(pm.response.responseTime).to.be.below(500); });
This test allows a slower response time up to 1 second.
Postman
pm.test("Response time is acceptable", function () { pm.expect(pm.response.responseTime).to.be.below(1000); });
This test expects a very fast response under 100 milliseconds.
Postman
pm.test("Response time is fast", function () { pm.expect(pm.response.responseTime).to.be.below(100); });
Sample Program
This Postman test script checks if the API response time is under 300 milliseconds. If the response is faster, the test passes. If slower, it fails.
Postman
pm.test("Response time is less than 300ms", function () { pm.expect(pm.response.responseTime).to.be.below(300); });
OutputSuccess
Important Notes
Response time can vary depending on network speed and server load.
Set realistic time limits based on your application's needs.
Run tests multiple times to get an average response time.
Summary
Response time benchmarking measures how fast a system responds.
Use Postman's pm.response.responseTime to check response speed.
Set assertions to ensure response times meet your performance goals.