Discussion:
accept ... from time
(too old to reply)
m***@web.de
2007-01-23 12:18:21 UTC
Permalink
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 13:38:04 UTC
Permalink
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)
Post by m***@web.de
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
m***@web.de
2007-01-23 12:57:03 UTC
Permalink
Yes correct. MF 8 Digit Time includes Milliseconds. That`s what I need.

Kind regards

Michael
Rick Smith
2007-01-23 16:06:47 UTC
Permalink
Post by m***@web.de
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 17:13:16 UTC
Permalink
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-bin/bookmgr_OS390/BOOKS/CEEA3170/2.2.5.48

For details. (Other vendors may have similar non-Standard services).
--
Bill Klein
wmklein <at> ix.netcom.com
Post by m***@web.de
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 19:07:29 UTC
Permalink
Post by m***@web.de
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 04:31:18 UTC
Permalink
Post by Richard
Post by m***@web.de
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 all quite true.
Post by Richard
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").
Post by Richard
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- .
Robert Jones
2007-01-23 20:33:00 UTC
Permalink
Bottom posting
Post by m***@web.de
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
As well as the other approaches, you could consider using

EXEC SQL SET :time-variable = CURRENT TIME END-EXEC or similar

As there may be an overhead invoking the DB2 processor, you could run
two such statements in sequence to see what the latent delay is and as
someone else suggested, it would be a good idea to check the
granuarity, perhaps by executing several in sequence, to get an idea of
the "accuracy" (if that's quite the right term) available.
Michael Mattias
2007-01-23 23:41:25 UTC
Permalink
Post by m***@web.de
I want to measure the execution time of a sql statement. Can I get the
time in milliseconds to be displayed.
Call me an old fuddy-duddy, but millisecond accuracy s going to be so
dependent on other factors such as current demands on database server and
current network traffic that milliseconds are meaningless

"But," says you, " I willl be doing THOUSANDS of these and those
milliseconds will add up in a big hurry!"

The obvious answer is ... do your thousands of executions and divide by the
number of same to get a 'unit time cost.' Hell, this will be more accurate
than doing onesies and twosies anyway.

(Ummm....I assume the statement is already PREPARED? Otherwise the
preparation time (parse and plan) will be inseparable from the execution
time).
--
Michael C. Mattias
Tal Systems Inc.
Racine WI
***@talsystems.com
Loading...