Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to return time value to thousandths of a second?

Status
Not open for further replies.

alanplayford

Technical User
Oct 10, 2006
3
GB
I'm converting a heap of Assembler programs to MF Cobol, one of which uses the BAL "TIME" macro to get the system time in format hhmmssttt.
I'm using the COBOL FUNCTION CURRENT-DATE to do the same, but this only returns time to a precision of hhmmsshh.

Is there any way of getting more precision out of the function, chaps?
 
Sorry, Frederico!
Cobverting BAL from IBM Enterprise System to COBOL on Windows PC using MicroFocus Mainframe Express (MF COBOL), v3.1
 
I don't know about thousandth of a seconds but in Tandem system I usually use micro seconds (millionth of a second)
which is 1000000 micro seconds. A practical usage is when you are trying to find the days or time differences between two dates and time. You simply convert hours, minutes and seconds
into micro seconds then add all the micro seconds.

Here's some numbers (it's been a long time so I hope it is the correct conversion):

Hours * 3600000000 = total micro seconds in an hr.
Minutes * 60000000 = total micro second in a minute.
Seconds * 1000000 = total micro seconds in a second.

Your working storage should be like PIC 9S(18) COMP.


 
You might want to use LE callable services to get the local time in YYYYMMDDHHMMSS999 format (CEELOCT). Check the LE programming guide for details.

Regards,

Glenn
 
Thanks to all who responded.

3gm, I have tried the CEELOCT option (have to set LE environment option to enable), but actually this cheats a little, and the CEELOCT program code always inserts a zero in the thousandths position. It therefore returns the same precision as the ACCEPT or FUNCTION methods, it only appears at first glance to be more precision?

I'm currently experimenting with the WINAPI functions such as "GetSystemTime" etc. these appear a little better, but apparently the Windoze hardware tends to jump in iuncrements of several thousandths of a second. Guess it just doesn't think anybody would want more precision? :eek:)

I'll plough on, but this appears to be a problem that many people have found in the past, and it depends on your platform as to which options are available (e.g. Unix has a diffenent environmental function)
 
Hi There,

IIRC - The intrinsic FUNCTION CURRENT-DATE in Enterprise COBOL can give you resolution up to 100th of a second.

Guess it just doesn't think anybody would want more precision?
How is one more digit of precision needed for this requirement?


If you really, really must, suggest you consider an assembler STCK (or STCKE if you want to cover the STCK overflow in 2042).
 
I'm currently experimenting with the WINAPI functions such as "GetSystemTime" etc. these appear a little better, but apparently the Windoze hardware tends to jump in iuncrements of several thousandths of a second. Guess it just doesn't think anybody would want more precision?

I don't know precisely what your programs are looking to do, but if you're timing something, GetSystemTime isn't what you want. All it's good for is getting the date and time out of the system into your program, and from the comment you made, I guess that's NOT what you're doing.

These two are what you want if you want to time stuff:
QueryPerformanceFrequency
QueryPerformanceCounter

and if worse comes to worse and you're on a 9X series box, use:

timeGetTime



Measurement is not management.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top