Home > Archive > Cobol > January 2007 > accept ... from time
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
accept ... from time
|
|
| michael.bierenfeld@web.de 2007-01-23, 7:55 am |
| Hello,
I want to measure the execution time of a sql statement. Can I get the
time in milliseconds to be displayed.
I have
accept START-TIME from time
EXEC SQL SELECT ... something
accept END-TIME from time
DISPLAY "EXECUTION lasted from" START-TIME
DISPLAY " till " END-TIME
START-TIME and END-TIME is pic x(8) this is hh24:mm:ss. But I need
fractions of seconds. How can I do this. Target System is Microfocus
and AIX.
Kind Regards
Michael
| |
| Vaclav Snajdr 2007-01-23, 7:55 am |
| My experience with MF says that it is different from operationg system
and MF-Cobol-Version if the time is 6 or 8 digits. The newest versions
are 8 digits. I use numeric fields for time, f.e. START-ZEIT PIC 9(8) COMP.
and receive f.e. 13250135 now. (35 hunderstel der Sekunde, der Sprung ist 0
und 5 hunderstell)
michael.bierenfeld@web.de wrote:
> Hello,
>
> I want to measure the execution time of a sql statement. Can I get the
> time in milliseconds to be displayed.
>
> I have
>
> accept START-TIME from time
>
> EXEC SQL SELECT ... something
>
> accept END-TIME from time
>
> DISPLAY "EXECUTION lasted from" START-TIME
> DISPLAY " till " END-TIME
>
> START-TIME and END-TIME is pic x(8) this is hh24:mm:ss. But I need
> fractions of seconds. How can I do this. Target System is Microfocus
> and AIX.
>
> Kind Regards
>
> Michael
--
Vaclav Snajdr
| |
| michael.bierenfeld@web.de 2007-01-23, 7:55 am |
|
Yes correct. MF 8 Digit Time includes Milliseconds. That`s what I need.
Kind regards
Michael
| |
| Rick Smith 2007-01-23, 6:55 pm |
|
<michael.bierenfeld@web.de> wrote in message
news:1169554701.175132.59070@s48g2000cws.googlegroups.com...
> Hello,
>
> I want to measure the execution time of a sql statement. Can I get the
> time in milliseconds to be displayed.
>
> I have
>
> accept START-TIME from time
>
> EXEC SQL SELECT ... something
>
> accept END-TIME from time
>
> DISPLAY "EXECUTION lasted from" START-TIME
> DISPLAY " till " END-TIME
>
> START-TIME and END-TIME is pic x(8) this is hh24:mm:ss. But I need
> fractions of seconds. How can I do this. Target System is Microfocus
> and AIX.
I have used the following for timing.
Resolution is 10 ms for code; but may be different
depending on hardware, OS, etc. For example,
a PC with DOS has a resolution of 55 ms.
-----
data division.
working-storage section.
01 t-start.
03 t-start-hour pic 99.
03 t-start-minute pic 99.
03 t-start-second pic 99v99.
01 t-end.
03 t-end-hour pic 99.
03 t-end-minute pic 99.
03 t-end-second pic 99v99.
77 t-elapsed pic 9(7)v99.
77 t-elapsed-display pic z(6)9.99.
procedure division.
...
accept t-start from time
* insert what is to be timed, here
accept t-end from time
perform display-elapsed
...
display-elapsed section.
if t-start > t-end
* execution past midnight
move 86400 to t-elapsed
else
move 0 to t-elapsed
end-if
compute t-elapsed = t-elapsed
+ (t-end-hour - t-start-hour) * 3600
+ (t-end-minute - t-start-minute) * 60
+ (t-end-second - t-start-second)
end-compute
move t-elapsed to t-elapsed-display
display t-elapsed-display
| |
| William M. Klein 2007-01-23, 6:55 pm |
| The following is what the current Micro Focus LRM states (and I believe this is
what the ANSI/ISO Standards do - and have always - required)
"TIME is composed of the data elements: hours, minutes, seconds and hundredths
of a second. TIME is based on elapsed time after midnight on a 24-hour clock
basis - thus, 2:41 P.M. would be expressed as 14410000. TIME, when accessed by a
COBOL program behaves as if it had been described in a COBOL program as an
unsigned elementary numeric integer data item eight digits in length. The
minimum value of TIME is 00000000; the maximum value of TIME is 23595999. If the
hardware does not have the facility to provide fractional parts of TIME, the
value is converted to the closest decimal approximation. "
In other words, you can only get HUNDREDTHS of a second using ACCEPT FROM TIME.
***
On the OTHER HAND,
If you are running in an IBM mainframe environment with LE (or in an
environment with "LE-emulation" such as that provided by Micro Focus in some of
their products), you can look at the CEELOCT "callable service" to get
thousandths of a second. See
http://publibz.boulder.ibm.com/cgi-...EA3170/2.2.5.48
For details. (Other vendors may have similar non-Standard services).
--
Bill Klein
wmklein <at> ix.netcom.com
<michael.bierenfeld@web.de> wrote in message
news:1169554701.175132.59070@s48g2000cws.googlegroups.com...
> Hello,
>
> I want to measure the execution time of a sql statement. Can I get the
> time in milliseconds to be displayed.
>
> I have
>
> accept START-TIME from time
>
> EXEC SQL SELECT ... something
>
> accept END-TIME from time
>
> DISPLAY "EXECUTION lasted from" START-TIME
> DISPLAY " till " END-TIME
>
> START-TIME and END-TIME is pic x(8) this is hh24:mm:ss. But I need
> fractions of seconds. How can I do this. Target System is Microfocus
> and AIX.
>
> Kind Regards
>
> Michael
>
| |
| Richard 2007-01-23, 6:55 pm |
|
michael.bierenfeld@web.de wrote:
> I want to measure the execution time of a sql statement. Can I get the
> time in milliseconds to be displayed.
> START-TIME and END-TIME is pic x(8) this is hh24:mm:ss. But I need
> fractions of seconds. How can I do this. Target System is Microfocus
> and AIX.
You should check first the granularity of the time you receive. If you
accepted the time several times in a loop you may find that you get the
same time for several successive accepts and then a jump to the next
time which may be tens of milliseconds later.
That is there may be only a few different times that you receive in
each second. On PCs you will only get 18 different times in one second
no matter how many accepts are done. On AIX this may be higher.
If you need millisecond, or actual hundredths, you may need to use some
other mechanism.
| |
| Douglas Wells 2007-01-25, 3:55 am |
| In article <1169579249.376053.109300@k78g2000cwa.googlegroups.com>, "Richard" <riplin@Azonic.co.nz> writes:
>
> michael.bierenfeld@web.de wrote:
>
>
>
> You should check first the granularity of the time you receive. If you
> accepted the time several times in a loop you may find that you get the
> same time for several successive accepts and then a jump to the next
> time which may be tens of milliseconds later.
That is all quite true.
> That is there may be only a few different times that you receive in
> each second. On PCs you will only get 18 different times in one second
> no matter how many accepts are done. On AIX this may be higher.
The first statement is true. The second is false.
I have just verified that at least one existing implementation on
a "PC" provides full centisecond precision, namely Tinycobol 0.63.0
running on FreeBSD on an x86 box (although it has a really nasty
wraparound bug at the seconds level).
I believe that you have misunderstood an implementation artifact
of MS-DOS/PC-DOS and the underlying BIOS. Every IBM-PC architecture
machine has an internal hardware timer that ticks at approximately
a microsecond rate (starting with the first ones back in 1981).
The BIOS uses this timer to generate time interrupts. It uses the
slowest possible interrupt rate of interrupting approximately every
65K ticks (presumably to reduce interrupt processing overhead).
If you divide those out, you will see that interrupts occur about
18 times per second. (The BIOS timer actually ticks at 14318180 /
12 / 65536 HZ, which comes out to the documented 18.2 ticks per
second.)
Numerous third-party PC-DOS and MS-DOS programs altered the interrupt
rate to provide higher precision timers, and since about 1990,
most POSIX-inspired OSs on x86 platforms have provided access to
the full microsecond precision (via the BSD "gettimeofday" call).
Even Windows NT-derived systems have used a higher rate: since
at least NT 4 (I can't verify earlier systems), the OS has "ticked"
at a 100 HZ rate (or faster) and provided full access to a microsecond
timer (via the "Performance Counter").
> If you need millisecond, or actual hundredths, you may need to use some
> other mechanism.
Yes. I have verified that both Tinycobol and OpenCobol (0.32) are
capable of providing access to the microsecond precision of the
system timer (of the some platform) via an external call (e.g.,
'CALL "gettimeofday" USING timeofday BY VALUE 0' in both dialects).
The OP doesn't mention which of the various AIX platforms he is
using, and I don't know enough about MicroFocus's product time to
guess, but I would imagine that some appropriate mechanism could
be jury-rigged whatever the platform. In addition, AIX is a
certified UNIX system, which means that it is required to provide
a clock precision of at least 50 ticks per second.
(Sorry if that's more information than you wanted to know.)
- dmw
--
.. Douglas Wells . Connection Technologies .
.. Internet: -sp9804- -at - contek.com- .
|
|
|
|
|