Focal Point
How to find total time taken to run a FEX

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/8271097331

August 23, 2004, 04:21 PM
RB
How to find total time taken to run a FEX
Hi,

How can we find out the total time taken to run a procedure?

Thank you.
August 23, 2004, 05:28 PM
<Pietro De Santis>
There are three system variables:

&FOCCPU Calculates the operating system CPU time in milliseconds.

&FOCTTIME Calculates total CPU time in milliseconds.

&FOCVTIME Calculates virtual CPU time in milliseconds.

Not sure what the differences between these are.

It's best to try them out.
August 23, 2004, 05:37 PM
<Pietro De Santis>
It's more accurate if you do it yourself.

Put this at the top of the program:

-* Set Report Start Date and Time
-SET ST_DATE = &YYMD;
-SET ST_TIME = EDIT(HHMMSS('A8'),'99$99$99');

Put this at the bottom of the program:

-* Set Report End Date and Time
-SET &EN_DATE = &YYMD;
-SET &EN_TIME = EDIT(HHMMSS('A8'),'99$99$99');

-SET &ST_HH = EDIT(&ST_TIME,'99$$$$');
-SET &ST_MM = EDIT(&ST_TIME,'$$99$$');
-SET &ST_SS = EDIT(&ST_TIME,'$$$$99');

-SET &EN_HH = EDIT(&EN_TIME,'99$$$$');
-SET &EN_MM = EDIT(&EN_TIME,'$$99$$');
-SET &EN_SS = EDIT(&EN_TIME,'$$$$99');

-SET &EN_HH =
- IF &EN_DATE GT &ST_DATE THEN &EN_HH + 24 ELSE &EN_HH;

-SET &ST_TIME_S = (&ST_HH * 60 *60) + (&ST_MM * 60) + &ST_SS;
-SET &EN_TIME_S = (&EN_HH * 60 *60) + (&EN_MM * 60) + &EN_SS;

-SET &ELAPSED_S = &EN_TIME_S - &ST_TIME_S;
-SET &ELAPSED_M = &ELAPSED_S / 60;
-SET &ELAPSED_R = FMOD(&ELAPSED_S, 60, 'F2');

-TYPE
-TYPE Report elapsed time: &ELAPSED_M mins &ELAPSED_R secs

For convenience, put the two pieces of code into fexes that you -INCLUDE into your report program.
August 23, 2004, 08:55 PM
RB
Hi Pietro,

Second one works well. I do not think &variables are giving the right time. Thank you for the solution.

I have one more idea that works.

Include this at the beginning of the program
-SET &STARTIME = HHMMSS(STIME);
-TYPE &STARTIME

Include this at the end of the program
-SET &ENDTIME = HHMMSS(ETIME);
-TYPE &ENDTIME
August 24, 2004, 02:36 PM
Tom Walker
How about this variation...

-SET &BEGTIME = HGETC(10,'HYYMDm');
-RUN

TABLE FILE ...
etc
etc


-SET &ENDTIME = HGETC(10,'HYYMDm');
-SET &SECS = HDIFF(&ENDTIME, &BEGTIME, 'SECOND', D12.2);
-SET &MILSEC = HDIFF(&ENDTIME, &BEGTIME, 'MILLISECOND', D12.2);
-TYPE Execution time in seconds = &SECS
-TYPE Execution time in mili-seconds = &MILSEC
-EXIT
August 24, 2004, 03:46 PM
susannah
so cool to know, kudos and thanks rb and tom.
I'd been using &tod and suffering.
This is great
August 24, 2004, 05:16 PM
<Pietro De Santis>
Tom, thanks for your suggestion, nice and clean.
August 24, 2004, 06:54 PM
RB
Thank you Tom. It never stuck to me that we can DIFF functions for the difference.
August 24, 2004, 07:36 PM
Tom Walker
I get a lot of date-time formatting tips from the presentation Renee Teatro gave in New Orleans titled, "That's not a date-time datatype, is it?". The link for the power point presentations is

http://www.informationbuilders.com/events/summit04/pres...Not_a_Date_TimeC.ppt
August 25, 2004, 07:29 PM
RB
A very good presentation. Thank you for the link!
May 02, 2006, 02:01 PM
dballest
I tried doing RB's suggestion:

Include this at the beginning of the program
-SET &STARTIME = HHMMSS(STIME);
-TYPE &STARTIME

Include this at the end of the program
-SET &ENDTIME = HHMMSS(ETIME);
-TYPE &ENDTIME

But it looks like it is not working. The start time is the same as the end time. I have a long report that when I time it using a stopwatch takes about 2 mins.

Am I missing something?

Thanks,
Dan


Dev: WebFOCUS 7.6.10, Data Migrator 7.6.10
QA: WebFOCUS 7.6.10, Data Migrator 7.6.10
Prod: WebFOCUS 7.6.2, Data Migrator 7.6.8
Windows 2K3, Tomcat 5.5.17, IIS 6
Usage: HTML, PDF, Excel, Self-serve, BID and MRE
May 02, 2006, 02:22 PM
dwf
Possibly. Be sure you have a -RUN after the END statement of your TABLE FILE (and before the last -SET &ENDTIME). Otherwise, both the times will be captured before the report runs.


dwf
May 02, 2006, 03:20 PM
reFOCUSing
You will need something like this:
-SET &STARTIME = HHMMSS(STIME);
-TYPE &STARTIME
-RUN

-* Replace LOOP with reporting code.
-SET &TOKEN = 0;
-REPEAT :LOOP FOR &INDX FROM 1 TO 10000 STEP 1;
-SET &TOKEN = &TOKEN + 1;
-:LOOP

-SET &ENDTIME = HHMMSS(ETIME);
-TYPE &ENDTIME
-RUN

May 02, 2006, 04:31 PM
dballest
dwf & reFOCUSING,

My program is acting strange. Below is the code:

-SET &STARTIME = HHMMSS(STIME);
-TYPE &STARTIME
-RUN

TABLE FILE ONE
:
:
END
-RUN

-SET &ENDTIME = HHMMSS(ETIME);
-TYPE &ENDTIME
-RUN

Output:
1. With the above code, when I view the source, it ends at the end of the table file. I don't see ENDTIME at all.

2. But when I remove -RUN after the TABLE FILE, I can see ENDTIME but the value is the same as the STARTIME.


Dev: WebFOCUS 7.6.10, Data Migrator 7.6.10
QA: WebFOCUS 7.6.10, Data Migrator 7.6.10
Prod: WebFOCUS 7.6.2, Data Migrator 7.6.8
Windows 2K3, Tomcat 5.5.17, IIS 6
Usage: HTML, PDF, Excel, Self-serve, BID and MRE
May 02, 2006, 04:53 PM
dwf
Ah. Just noticed. When using HHMMSS in Dialogue Manager, you need to specify the format in parenthesis, not the variable name.

-SET &STARTIME = HHMMSS('A8');
-TYPE &STARTIME
.
.
.
-SET &ENDTIME = HHMMSS('A8');
-TYPE &ENDTIME


Not sure how you even got a result before


dwf
May 02, 2006, 05:41 PM
dballest
dwf,

I'm now able to see the ENDTIME after I remove the -RUN command on the TABLE FILE before it. Thanks for all the help!

Dan


Dev: WebFOCUS 7.6.10, Data Migrator 7.6.10
QA: WebFOCUS 7.6.10, Data Migrator 7.6.10
Prod: WebFOCUS 7.6.2, Data Migrator 7.6.8
Windows 2K3, Tomcat 5.5.17, IIS 6
Usage: HTML, PDF, Excel, Self-serve, BID and MRE
May 03, 2006, 03:54 AM
Tony A
Dan,

One of the bugbears that has always been commented upon is the fact that &TOD has always been set to the time at which the FOCUS session began. Over time this has become to be viewed as an asset because, combined with the HHMMSS function you can get that elapsed timing you require.

Taking advantage of the above facts, you can declare a function in your profile(s) that will then always be available -

-* Calculate seconds between final and initial time.
DEFINE FUNCTION ELAPSED(X/A1)
DAY/YYMD = HDATE(TODAY('A10'),'YYMD');
DATE/A6YMD = DAY;
BEGTIME/A8 = EDIT('&TOD.EVAL', '99$:99$:99');
ENDTIME/A8 = EDIT(HHMMSS('A8'), '99$:99$:99');
BEGAN/A20 = DATE | ' ' | BEGTIME;
ENDED/A20 = DATE | ' ' | ENDTIME;
-* Convert to time stamps
DATE_TIME1/HYYMDSA=HINPUT(20,BEGAN,10,'HYYMDS');
DATE_TIME2/HYYMDSA=HINPUT(20,ENDED,10,'HYYMDS');
-*Subtract the two time stamps, getting difference in seconds
ELAPSED/D12.2=HDIFF(DATE_TIME2, DATE_TIME1, 'SECOND', 'D12.2');
END
-RUN
-* The RUN is important to ensure that the define is actioned immediately and therefore available
-* when required.


Then when you want to access the elasped time, just set a variable to the function output value -

-* Find elapsed time
-SET &ELAPSED = ELAPSED('X');


This will cover all your elapsed timing needs (or should do?).

T

This message has been edited. Last edited by: Tony A,



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10