Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

How to capture response time?

LegacyForum
LegacyForum Posts: 1,664 ✭✭
edited December 2016 in SOAtest
While running the regression controls in SOA for each operation, we are giving some 100-200 inputs. And for each we can see the response time as well. Is there any default method, by which we can capture these response times per input and export them into an excel sheet.

Tagged:

Comments

  • LegacyForum
    LegacyForum Posts: 1,664 ✭✭
    Hello,

    What is your goal in exporting the response times?

    You may want to look into SOAtest's load testing features. Load testing may help you achieve you goal.
    It will allow you to capture the response times and other performance data.
    You can then export the performance data and import it into Excel.

    Please let me know if you have any additional questions.

    ~Joe
  • LegacyForum
    LegacyForum Posts: 1,664 ✭✭
    Ok. We have some different sets of inputs, which will fetch the data from the different tables in the same database. So it's like one input would get the data from one table, but another input will take the data from 2 or 3 tables as the case may be. So depending on the response time that each input takes, we can try to tune from SQL procs.

    I got some scripts for getting the response time from another post in the same forum. "SOA Test:Transaction Time, Transaction Time for each Tests"

    1. Chain to the Request SOAP Envelope a Method tool with the following Python implementation:

    from com.parasoft.api import Context
    from java.lang import System

    def putTime(input, context):
    context.put("Test time", System.currentTimeMillis())

    2. Then to the Response SOAP Envelope, chain another Method tool with the following Python implementation

    from com.parasoft.api import Context
    from com.parasoft.api import Application
    from java.lang import System
    from java.lang import Long

    def printTime(input, context):
    t = context.get("Test time")
    diff = System.currentTimeMillis() - Long.valueOf(str(t))
    Application.showMessage("Total execution time: " + str(diff) + "ms")

    I tried this and in the result am getting some different time. Please let me know which is the TOTAL EXECUTION TIME.

    In the response, near the EXECUTION TIME I am getting 20734ms, where as the above method in the result is displaying 16ms.

    So I was just wondering what exactly is the time, thats being measured by the above method. and which time should be considered as the actual response time.

    Find the attachments The one in the blue box at the top is given along with the response, but the one below, i got by using the methods given above.

    Shyam!
  • LegacyForum
    LegacyForum Posts: 1,664 ✭✭
    Hello,

    In looking at the screen shot. I see that the 2 method are both chained to the Request. One should be chained to the response.

    Alternatively, you could chain a method tool to the Traffic Object and do this:
    CODE
    def printTime(input,context):
    reqTime = input.get("XML Request Time").getTime()
    respTime = input.get("XML Response Time").getTime()
    Application.showMessage(str(respTime - reqTime))


    Please let me know if this works for you.

    ~Joe
  • LegacyForum
    LegacyForum Posts: 1,664 ✭✭
    Hi,

    Yes I chained one method to request and another to response. But still I can see some small differences in the values. This is not much a concern for me as what I need to know is approzimately how much time it took for the response to come back.

    But still just for the information
    Input 1 - Execution Time ( 19703 ms) But using the methods the time is 19735 ms
    Input 2 - Execution Time (20171 ms) but using the methods the time is 20203 ms

    I Also tried the traffic object method which you gave me, but I am getting some WRONG SYNTAX messages like shown below. So it's not getting enabled and it's not having any effect during the run. Please let me know what to do?

    Traceback (innermost last):
    (no code object) at line 0
    SyntaxError: ('invalid syntax', ('<string>', 2, 1, 'reqTime = input.get("XML Request Time").getTime() '))

    Regards,
    Shyam!
  • LegacyForum
    LegacyForum Posts: 1,664 ✭✭
    Hello,

    The small differences in time is due to the time it takes to actually execute the method.
    Using the traffic object should be more accurate.

    I believe that error is due to indentation. Can you confirm that the code copied over to SOAtest correctly with the indentation on all but the def line?

    ~Joe
  • LegacyForum
    LegacyForum Posts: 1,664 ✭✭
    Hi,

    I tried the alternative method which you gave me. But even after I put in the format as you specified, it's giving some other error like "Traceback (innermost last): File "<string>", line4, in printTime NameError: Application". So I would require some more of your help in correcting this. I am not that very much familiar with python scripting.

    However, using the first method given, this time I am getting very large difference in the times recored by the method and by SOA tool. Find the attached excel sheet in which I have put a sample comparison


    No Response time as per method Response time in SOA
    1 Total execution time: 63ms 47ms
    2 Total execution time: 62ms 32ms
    3 Total execution time: 47ms 31ms
    4 Total execution time: 47ms 47ms
    5 Total execution time: 31ms 31ms
    6 Total execution time: 47ms 31ms
    7 Total execution time: 47ms 31ms
    8 Total execution time: 79ms 32ms
    9 Total execution time: 31ms 31ms
    10 Total execution time: 47ms 47ms
    11 Total execution time: 62ms 46ms
    12 Total execution time: 31ms 31ms
    13 Total execution time: 62ms 46ms
    14 Total execution time: 31ms 31ms
    15 Total execution time: 46ms 31ms
    16 Total execution time: 32ms 32ms
    17 Total execution time: 47ms 32ms
    18 Total execution time: 47ms 31ms
    Test succeeded


    THIS IS BECAUSE I WAS PREVENTED FROM UPLOADING THE EXCEL SHEET. """" Upload failed. You are not permitted to upload this type of file""""

    Regards,
    Shyam

  • LegacyForum
    LegacyForum Posts: 1,664 ✭✭
    Hello,

    You're missing the import required for the Application object. Sorry, I did not make it clear that it was needed.

    The complete code should look like this:
    CODE
    from com.parasoft.api import *

    def printTime(input,context):
    reqTime = input.get("XML Request Time").getTime()
    respTime = input.get("XML Response Time").getTime()
    Application.showMessage(str(respTime - reqTime))


    ~Joe
  • LegacyForum
    LegacyForum Posts: 1,664 ✭✭
    Thanks a lot..

    this is working fine and giving the accurate results.

    Thanks
    Shyam
  • Can you please let me know the time format when retrieving the getTime method.
    reqTime=input.get("XML Request Time").getTime()

    What is the time format of reqTime value.

  • benken_parasoft
    benken_parasoft Posts: 1,302 ✭✭✭

    Please see the script I posted near the top of this thread:
    https://forums.parasoft.com/discussion/3189/get-data-from-traffic-viewer-object

    input.get(SOAPUtil.REQUEST_TIME) or input.get(SOAPUtil.RESPONSE_TIME) return a java.util.Date Object. Java has other APIs for taking a Date object and converting it to a string in a particular format. In particular, there is java.text. SimpleDateFormat which has a format(Date) method.