IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Display the time my job ran for.


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
anjani shanker

New User


Joined: 26 Jan 2007
Posts: 37
Location: USA

PostPosted: Tue Apr 01, 2008 8:45 pm
Reply with quote

How can i display the time for which my program(Simple cobol codes including the SQLs) ran. Means the time taken between I submitted my job and the time I got the return code.

Please provide me with the suggestions.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19243
Location: Inside the Matrix

PostPosted: Tue Apr 01, 2008 9:30 pm
Reply with quote

Hello,

Display the time when your program enters the PROCEDURE DIVISION and again display the time when you "get the return code".
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6248
Location: Mumbai, India

PostPosted: Tue Apr 01, 2008 10:01 pm
Reply with quote

or look into JESMSGLG of a JOB. There can be alternate way if you've JHS installed at your shop.
Back to top
View user's profile Send private message
anjani shanker

New User


Joined: 26 Jan 2007
Posts: 37
Location: USA

PostPosted: Tue Apr 01, 2008 10:08 pm
Reply with quote

Hello Anuj & DS,

Anuj,
Regarding the Jesmsglg, i can only see the start and end time....I need this time to be displayed in my program.

DS,
Do you have any idea regarding how can i display the time when the pgm enters P.D. and the time it finds the stop run command.
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Tue Apr 01, 2008 10:24 pm
Reply with quote

You would have to display the end time before the stop run. See Dick's message above.
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 691
Location: Earth

PostPosted: Tue Apr 01, 2008 10:32 pm
Reply with quote

use CURRENT-DATE intrinsic function to get current time.
OR
use ACCEPT TIME-VAR from TIME
OR
Use CURRENT_TIME special register to get time from DB2

.. then display the value you got in working storage variable.
See the manual if you need more help in using above suggestions.

As already suggested by Craq and Dick ( Good rhyming, isn't it? icon_smile.gif ) you have to do it twice, after PROCEDURE DIVISION and before the STOP RUN.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19243
Location: Inside the Matrix

PostPosted: Tue Apr 01, 2008 10:36 pm
Reply with quote

Hello,

Do you want to know when the "return code" is returned or when the program is going to terminate? There could be some amount of time elapse between the return code and the termination. . .

Code:
ACCEPT MY-TIME FROM TIME.
DISPLAY MY-TIME.
will do what you want.
Back to top
View user's profile Send private message
anjani shanker

New User


Joined: 26 Jan 2007
Posts: 37
Location: USA

PostPosted: Tue Apr 01, 2008 10:47 pm
Reply with quote

Thanks everyone for putting inputs...

I have opted displaying the time twice as said by DS just after P.D. and just before Stop run.

Also wanted to check if there is any intrinsic function available for my requirement as we have functions like when-compiled. I guess there are no such function available.Am I right???
Back to top
View user's profile Send private message
anjani shanker

New User


Joined: 26 Jan 2007
Posts: 37
Location: USA

PostPosted: Tue Apr 01, 2008 10:51 pm
Reply with quote

D.S.

Actually i wanted to display for how much my program run. I have better explanation for this.

I wanted to display the difference of

STARTED - TIME=08.34.21
ENDED - TIME=08.34.22 of

JESMSGLG
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19243
Location: Inside the Matrix

PostPosted: Tue Apr 01, 2008 11:51 pm
Reply with quote

Hello,

Without getting too fancy, you could convert the start and end times to seconds, subtract the "start second" from the "end second", and convert the answer back to hours, minutes, and seconds.

One simple check i'd include would be to ensure that the end time was later than the start time.

How elegant you make the solution depends on if the job is of fairly short duration and if it might run over midnight. If the job(s) run over midnight, add 86400 (if i did it right, that is the number of seconds in a day) to the "end second" before subtracting.
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Tue Apr 01, 2008 11:55 pm
Reply with quote

Convert hours to seconds and minutes to seconds then subtract the begin from the end. If the difference is negative add 86400 to results. Divide the results by 60 to get minutes with the remainder as seconds, divide the minutes by 60 to get hours with the remainder as minutes.

If your job never runs more than 24 hours this will work.

Code:
COMPUTE START-TIME = (START-HOURS * 3600) + (START-MINUTES * 60) + START-SECONDS.
COMPUTE END-TIME = (END-HOURS * 3600) + (END-MINUTES * 60) + END-SECONDS.
SUBTRACT START-TIME FROM END-TIME GIVING RUN-TIME.
IF RUN-TIME < 0
    ADD 86400 TO RUN-TIME
END-IF.
DIVIDE RUN-TIME BY 60 GIVING RUN-TIME REMAINDER RUN-SECONDS.
DIVIDE RUN-TIME BY 60 GIVING RUN-HOURS REMAINDER RUN-MINUTES.
Back to top
View user's profile Send private message
anjani shanker

New User


Joined: 26 Jan 2007
Posts: 37
Location: USA

PostPosted: Wed Apr 02, 2008 2:47 am
Reply with quote

Thanks Crag.....

It worked icon_smile.gif
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6248
Location: Mumbai, India

PostPosted: Wed Apr 02, 2008 4:55 am
Reply with quote

Hi Craiq,

Pehaps I was never in a need to implement the above, well, after reading the thread I'm still not sure about how to find time for this
Quote:
the time I got the return code

Can you please guide me what will be there in END-TIME, today i'm thinking too hard I guess..
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19243
Location: Inside the Matrix

PostPosted: Wed Apr 02, 2008 6:07 am
Reply with quote

Hi Anuj,

Quote:
what will be there in END-TIME,
END-TIME will have whatever time is in the system clock when the code gets it from the system variable.

Placement in the code would be entirely up to the coder. It could be when the return-code is detected after an sql statement or it could be at end-of-job or anywhere else that there was a need to see how much time had elapsed between 2 places in the code.
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6248
Location: Mumbai, India

PostPosted: Wed Apr 02, 2008 7:28 am
Reply with quote

Hi Dick,

dick scherrer wrote:
whatever time is in the system clock when the code gets it from the system variable.
Did you want to say there will be a statement like this
Code:
ACCEPT END-TIME FROM TIME.
in the program just before GOBACK ? If yes, I'm just curious to know, what will be the use of such an information..
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19243
Location: Inside the Matrix

PostPosted: Wed Apr 02, 2008 8:23 am
Reply with quote

Hi Anuj,

Quote:
what will be the use of such an information..
If one was to "accept the time" at the "start" of a process and at the "end" of a process, or a subroutine, or from one point until another, one could calculate the duration.

It is fairly common to want to know how long "something" takes. In this case the duration is clock tme rather than calendar time (i.e. days).

Look above at the previous replies. Both a description and the code to do this have been posted.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Apr 02, 2008 11:08 am
Reply with quote

This topic falls under 'useless information'. requirements of this silly nature are usually demanded by someone who knows nothing about computers.

all you are calculating is elapsed wall clock time.

if on monday I run this program and nothing else is running in the box, the elapsed time will be x.

if on tuesday I run this program and it is end of month, end of quarter, the box would probably be busy and the program would get time slices shared with 100 jobs instead of just 1. thus the elapsed time will be greater.

Depending upon services called by the job, the elapsed time will be even longer if the demand upon services (more jobs in the system) is greater; especially db2.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19243
Location: Inside the Matrix

PostPosted: Wed Apr 02, 2008 8:11 pm
Reply with quote

Hello,

Quote:
This topic falls under 'useless information'.
'Fraid i must not quite agree. . .

This can be a very easy way to get some numbers to isolate sections of problem code.

I've been invited to be part of several very large data conversion exercises (usually after it was discovered that there was not enough time for the comversion process to run in the cutover time-frame). To get some system to the "new replacement system", most of the existing data had to be converted. Some of these conversion programs would run for multiple days wall-time due to the way the they were implemented.

A common "offender" was the desire to use the "new" data validation routines to validate the old data to be converted. These routines were called-subroutines that were meant to support the online transactons that input new user data. In the "real" environment, they ran sub-second combined, but when there were from millions to hundreds of millions of validations, the one-at-time method came up very lacking.

By showing elapsed time at various places in the code the conversion teams were able to focus on which improvements gave the "biggest bang" for the time invested to get the performance to acceptable.

If several benchmarks were run with different machine loads, the numbers didn't mean much for posterity, but they did help point where to start with the process improvements.

FWIW. . .
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts To get the the current time DFSORT/ICETOOL 13
No new posts RC query -Time column CA Products 3
No new posts C Compile time time stamps Java & MQSeries 10
No new posts Parallelization in CICS to reduce res... CICS 4
No new posts Insert system time/date (timestamp) u... DFSORT/ICETOOL 5
Search our Forums:

Back to Top