Forum Discussion

Klaael's avatar
Klaael
New Contributor
5 years ago

Getting the milliseconds between 2 TestSteps

I am trying to check the performance of a deploy API.

 

I am using these steps to get the time it takes to deploy. 

 

-Start Time ([Groovy Script] This sets a custom property with the current time in this format "HH:mm:ss.SSS")

-Deploy ([API] This only start the job, we need another step to make sure the job is done and done right)

-Transfer jobID (Standard property transfer)

-Query Job Status ([API] This gets the status of a job from the jobID)

-Check Job Status ([Groovy Script] a script that goto "Query Job Status" if job is not complete)

-End Time (This sets a custom property with the current time in this format "HH:mm:ss.SSS" and adds 1 to a counter)

-Loop condition (If counter is not equal to predetermined amount, goto TestStep "StartTime")

 

How do I calculate the milliseconds between the 2 custom properties "StartTime" and "EndTime"?

Or

How do I get the time between 2 TestSteps?

Whichever makes more sense to use.

 

This is how I create the time stamp in the custom properties:

 

String strCurrentDate = new Date().format("HH:mm:ss.SSS")
startTlime = strCurrentDate
testRunner.testCase.setPropertyValue("StartTime", startTime)

 

 

This is my last attempt at getting the difference between the 2 values

 

def startTime = testRunner.testCase.getPropertyValue( 'StartTime' )
def endTime = testRunner.testCase.getPropertyValue( 'EndTime' )
Date ParsedStartTime = Date.parse("HH:mm:ss.SSS", startTime)
Date ParsedEndTime = Date.parse("HH:mm:ss.SSS", endTime)
Date rateDuration = Date.(ParsedEndTime - ParsedStartTime)

 

 

I've tried many ways to manipulate the data like String, Date, .format(), .parse(), alone and combined. I am not able to make it work

Any suggestions?

  • HimanshuTayal 

    That is the closest to what I've actually done.

     

    for every loop I write the times in a custom property with an iteration in the property name (StartTime1, EndTime1)

    The last step of the TC is a groovy script that logs all of the start and end time into a single text file which I import in Excel to parse and get results.

     

    I was hoping for soapui to get the final answer for this test but after all that research and the suggestions here, I think that only excel can offer me the answer I seek.

     

    Thanks to you two for the help.

  • nmrao's avatar
    nmrao
    Champion Level 3

    Even if there are no steps for getting start and end times, SoapUi collects or show time taken. Isn't it?

    You can see below how much time spend for each and step and cumulative.

    If you want the value, access it in TearDown script as shown below.

     

     

     

    • Klaael's avatar
      Klaael
      New Contributor

      nmrao 

      This would not work. The API starts the job and I need to know how much time it took to complete without the time of the other steps.

      I also need to run that at least 10 times to test the performance.

      • HimanshuTayal's avatar
        HimanshuTayal
        Community Hero

        Klaael :

         

        i would suggest that you would use any performance testing tool, if you want to do this via SoapUI, then you implement following structure:

         

        1. add Groovy Script before your Test Step

        2. write the start time into Properties Step with iteration number(as you want to run multiple times)

        3. add script assertion in your test step and write the time in Properties step with iteration number

        4. at the end calculate the time difference.