The original request was for a shortest code fragment. This likely meant
as line count, but could have been execution time.
I am using UniVerse 10.1.3 on a 1.7 GHz pentium. Here are some current
timings. Except for test 0001 which is an empty FOR NEXT loop, to the left
of the "|" is a hint of the initialization, and to the right is a hint of
the code under test.
An interesting result is that it is faster to assign SPACE(2) than to a
variable than assigning a 1 or 10 character string in a variable to another
variable.
The basic takeaway is that use of ICONV and OCONV should be minimized if
you optimize for time.
Test Loop Core...................... (uSec) per
Iteration.
0001 FOR/NEXT | (EMPTY) 0.081
0005 A=0 0.037
0012 |A=1+1 0.034
0050 IF (B) THEN -WIDE.IF 0.025
0051 IF (B) THEN WIDE.IF 0.031
0072 A=2;B=2|C=A*B 0.033
0201 A= 10x|B=A[1,1] 0.303
0221 A=SPACE(2)|A=SPACE(2) 0.283
0231 A:='12345':@VM...|B=A[char(253) 0.457
,10,1]
0338 A='11111'|B=OCONV(A,"D4/") 2.503
0352 A='11111'|B=OCONV(A,"D4-YMD[4,2 2.821
,2]")
0353 A='11111'|B=OCONV(A,"D4/");[7,4 3.986
]-[1,2]-[4,2]
0365 A=2;B=2|C=A/B 0.042
0369 A=2|B=INT(A) 0.293
0370 A=2.2|B=INT(A) 0.294
0371 A=2000|B=MOD(A,4) 0.236
0372 A=2001|B=MOD(A,4) 0.238
0374 A=SPACE( 1)|B=A 0.321
0375 A=SPACE( 10)|B=A 0.323
0376 A=SPACE( 100)|B=A 0.369
0377 A=SPACE( 1000)|B=A 0.559
0378 A=SPACE(10000)|B=A 1.727
0385 A='20040825'|B=ICONV(A,"D4") 0.879
0386 A='13387'|B=OCONV(A,"D4") 2.796
0387 A=13387|B=OCONV(A,"D4") 3.186
Mark A. Baldridge
Principal Consultant
North American Lab Services
DB2 and U2 Information Management, IBM Software Group
(508) 524-5666
-------
u2-users mailing list
[email protected]
To unsubscribe please visit http://listserver.u2ug.org/