This assertion tests that each response was received within a given amount of time. Any response that takes longer than the given number of time (milliseconds) specified by the user is marked as a failed response.
Let us look into an example :
Step 1. Right Click Test Plan > Add > Threads(Users) > Thread Group
Step 2. Thread Group > Add > Config Element > HTTP Request Default
Set Server Name as: google.com
Step 3. Thread Group>Add > Sampler > HTTP Request (Change name to Google Home Page)
Set Path as: /
Step 4. HTTP Request (Google Home Page) > Add > Assertions > Duration Assertion
Duration in Milliseconds - The maximum number of milliseconds each response is allowed before being marked as failed.
Set Duration in Milliseconds value as '1000'
In the above example google.com, if JMeter receives response within the specified time '1000' milliseconds then the result will be pass, else failed.
Now lets us decrease the value of Duration in Milliseconds value as '10'.
To view the Results, let us add Listener - > View Results in Table to check the time took to load the page.
Now run script again to expect the response as failed. When the Duration Assertion Fails, it will display message as 'Duration Assertion : The operation lasted too long: It took 296 milliseconds, but should not have lasted longer than 10 milliseconds.'
You can now check the sample time that took to load the Page Google.com
Now Check the Assertion Results with failed message
We can add Duration Response to Main Samplers or Sub Samplers. Please fell free to comment your queries on Duration Assertion.