Forum Discussion

Ned's avatar
Ned
Occasional Contributor
5 years ago
Solved

Getting the time a file is created

Can someone show me how to capture the time (ms) it takes to create a file?

 

I am testing the performance on how long will it take to display an image on a web app. I assume there are several ways in getting the time from the GUI side, but there is this JSON file that is created when the image gets displayed.

 

For instance,  user selects the scanned image he wants to view in the web app,  a cache folder is created, then a string of jpeg files are created, (i.e. file1.jpg, file2.jpg, file3.jpg .....then the JSON.file) Once the JSON.file is created the processing stops, meaning the image is generated and is displayed.

 

Can I get the timestamp of the first file created in the cache folder and compare it to the last file created (i.e JSON file) and show the time in seconds in the testcomplete log, this will be the time it took to load and display the image

 

Can this be done using the keywords scripting?

 

I hope someone can help me with this one.

 

  • Hi,

     

    aqFile.GetCreationTime() returns file creation date/time.

    Depending on the implementation of your tested application, time difference you've mentioned might or might not include the time required to render image(s) on screen.

     

    P.S. Unrelated, but out of curiosity: if there are a lot of large files and the network is slow (i.e. time difference will be big), what will this mean?

     

7 Replies

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    aqFile.GetCreationTime() returns file creation date/time.

    Depending on the implementation of your tested application, time difference you've mentioned might or might not include the time required to render image(s) on screen.

     

    P.S. Unrelated, but out of curiosity: if there are a lot of large files and the network is slow (i.e. time difference will be big), what will this mean?

     

    • Ned's avatar
      Ned
      Occasional Contributor

      The files are not big (avg 300KB), it needs to create 256 of these jpg files to get the image to display as expected.

      So my curiously was to get the time stamp instead and compare the differences using TestComplete.  That is how I am manually testing this at the moment, getting the timestamp of the first file created in the folder and the last but I want to automate this process.  This is why my question came about.

       

      Do you have a sample I can see using the aqFile.GetCreationTime() for getting the two timestamps and comparing it?

       

      • AlexKaras's avatar
        AlexKaras
        Champion Level 3

        Hi,

         

        Documentation for aqFile.GetCreationTime() contains an example. To get difference between two dates you may consider, for example, aqDateTime.TimeInterval() and aqConvert.TimeIntervalToStr(). Again, documentation contains code samples.

        I would say this is a plain technical answer to your exact question.

         

        Exact implementation might depend on your actual needs and requirements and actual desing and behaviour of the tested application. For example, taking time difference between timestamps of two local files, you are not counting the time it took to get the first file. Are there any requirements to count the time it takes to render obtained images and make tested application to become responsive to the user? From the end-user point of view, what is the impact of images loading process? Etc.

         

        You may also consider the approach suggested by Reshail : use aqPerformance object to get initial time stamp, initiate files download process (e.g. by clicking on the selected image preview), wait until the process completes (using whatever criteria that your end-user will use), get second time stamp and calculate time taken.

         

        P.S. 300KB by 256 files ends up with something like 75-80MB of download volume... But we know nothing about your tested application and expected operational environment, so it might be fine for you.