Skip to main content
Announcements
See why Qlik is a Leader in the 2024 Gartner® Magic Quadrant™ for Analytics & BI Platforms. Download Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Script run time

Hi All, i wanted to know if there is a function which can output the time taken to run the script from start to finish. this is something which is displayed when script is running (below is screen grab), just want to store this somehow.. thanks in advance

1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Hi

I think there is no function to calculate script run time instead to find the out we need to call subroutines

Try below code   use includes .

// Declare the variables

SET vStartTime=;

SET vEndTime=;

SET vTimeTake=;

// Start Load time

// Call before load time

Sub StartLoad

    // Assing now to Variable

    Let vStartTime = num(now());

End Sub;

// Sub to calculate time in Load

// Sub timeCalculate(vStartTime,vEndTime,vTableName,vMessage)

Sub timeCalculate(vTableName,vMessage)

     // Calculate the End Time

     Let vEndTime = num(now());

     // Initlize the time taken

     SET vTimeTake=;

     // Calculate the time Taken

     LET vTimeTake = Date(($(vEndTime) - $(vStartTime)),'hh:mm:ss');

    

     // LOG Table Writing

     Log:

     Load

         now(1) as TimeStamp,    

         '$(vTableName)' as TableName,    

         '$(vTimeTake)'  as LoadTime,

         '$(vMessage)'  as LogMessage

     AutoGenerate 1;   

     // Initlize the variables

     SET vStartTime=;

     SET vEndTime=;

     SET vTimeTake=;

End Sub;

Sub LogWrite

   

    // Store and Reload Log File

    Store Log into log.txt (txt);

    DROP Table Log;

       

End Sub

View solution in original post

6 Replies
santiago_respane
Specialist
Specialist

Hi!

You could configure your app to generate the log file for every execution, in there you will find start/end time and more execution details.

You can do it from "Document properties > General tab" and the "Generate logfile" box must be checked.

Let me know if this helps.

Kindest regards,

Anonymous
Not applicable
Author

I would say, take two variable at script level, say:

Variable at Staring point of script: Let VStart = now();

your code.....

Variable at Endingpoint of script: Let VEnd = now();


and now do like: Vend - Vstart

Anonymous
Not applicable
Author

Hi

I think there is no function to calculate script run time instead to find the out we need to call subroutines

Try below code   use includes .

// Declare the variables

SET vStartTime=;

SET vEndTime=;

SET vTimeTake=;

// Start Load time

// Call before load time

Sub StartLoad

    // Assing now to Variable

    Let vStartTime = num(now());

End Sub;

// Sub to calculate time in Load

// Sub timeCalculate(vStartTime,vEndTime,vTableName,vMessage)

Sub timeCalculate(vTableName,vMessage)

     // Calculate the End Time

     Let vEndTime = num(now());

     // Initlize the time taken

     SET vTimeTake=;

     // Calculate the time Taken

     LET vTimeTake = Date(($(vEndTime) - $(vStartTime)),'hh:mm:ss');

    

     // LOG Table Writing

     Log:

     Load

         now(1) as TimeStamp,    

         '$(vTableName)' as TableName,    

         '$(vTimeTake)'  as LoadTime,

         '$(vMessage)'  as LogMessage

     AutoGenerate 1;   

     // Initlize the variables

     SET vStartTime=;

     SET vEndTime=;

     SET vTimeTake=;

End Sub;

Sub LogWrite

   

    // Store and Reload Log File

    Store Log into log.txt (txt);

    DROP Table Log;

       

End Sub

roger_stone
Creator III
Creator III

At the start of the script:

LET varTimer = NOW();

.... your script ....

Then put these two lines at the end of the script (before any exit script statement)

LET varTimer=TIME(NOW() - varTimer);

TRACE Taken $(varTimer) to run;

Not applicable
Author

Thanks everyone..

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

If you set a start time at the beginning of the script:

LET vScriptStart = now(1);

You can add a text box to your app with the expression:

=interval(ReloadTime() - vScriptStart, 'hh:mm:ss')

-Rob