Forum Discussion

WMeng's avatar
WMeng
Occasional Contributor
15 years ago

Wait time between data row reads in a load test

Hi,

I have a situation in my load test where I want the thread to simulate some think time after executing a request by fetching a data row from a flat file. In other words I want to have some breathing space while a thread loops through each row of the data file. Is this possible? Any suggestions are welcome.


Thanks,
Srikanth

5 Replies

  • WMeng's avatar
    WMeng
    Occasional Contributor
    Hi Ole,

    If I add a delay teststep inside my loop, then the delay will essentially be fired in parallel with all the test steps. Suppose I add a delay of 100 ms and the slowest of all the test steps is 80 ms, then I get a net delay of 20ms before the datasource fetches the next row. In other words the delay that I add is dependent on the performance of the teststeps within that testcase.

    Thanks,
    Srikanth
  • Hi Srikanth!

    I think that I understand what you want to do. Here's how you could accomplish that:

    Create a Properties step immediately after the DataSource:
    Name               Value
    startingTime ${=System.currentTimeMillis() }

    Then later on in the TestCase, where you want to delay, create a Groovy Script TestStep with the following content:
    def TOTAL_TIME_TO_DELAY = 1000 //in milliseconds
    def startingTime = context.expand( '${Properties#startingTime}' )
    def timeAlreadyDelayed = System.currentTimeMillis() - Long.parseLong( startingTime )
    Thread.sleep( TOTAL_TIME_TO_DELAY - timeAlreadyDelayed )

    Hope that it works and makes sense to you
    /Henrik
    eviware.com
  • WMeng's avatar
    WMeng
    Occasional Contributor
    Thanks Henrik.

    Remember that the groovy teststep will be fired in parallel with all the other teststeps. Hence I believe timeAlreadyDelayed will almost always be zero. Therefore if there is any way I can get the slowest teststep and its response time dynamically then

    def timeAlreadyDelayed = System.currentTimeMillis() - Long.parseLong( response time of slowest request )

    Regards,
    Srikanth