I'am using two arrays of a 1000 date fields to store the result of my
routine "Check Date: Valid Or Not". This routine checks among the days
of the week, some calenders, to check wether a date is valid or not.
There for it has to do some database I/O and because it has to check
date's for about one million records, I store the result in the above
mentioned arrays. I check the arrays first before starting this
routine.
Still my programma is not running is fast as I want it to be ;-( !
Now I'am wondering what's the performance impact of the LOOKUP
operation code I use the check on these two arrays?
Ron
I don't know the exact implementation of LOOKUP in RPGLE, but the
corresponding LOKUP i RPG, had serious consequences for performance.
I use it myself, but seldom in situations where performance is a
consideration. I would suggest a workfile.
Niels Steen Madsen
Ron <kou...@iaehv.nl> skrev i artiklen
<35c99a03...@nntp.iaehv.nl>...
>This routine checks among the days
>of the week, some calenders, to check wether a date is valid or not.
BTW, for days of the week (e.g. if Sunday is never a valid business
day), I would just code a subprocedure to return the day of the week
and validate it before checking the arrays and DB files with other
less obvious dates (which I presume to be holidays, etc.)
Sample day of week routines have been posted here numerous times
lately.
Doug
>Still my programma is not running is fast as I want it to be ;-( !
>Now I'am wondering what's the performance impact of the LOOKUP
>operation code I use the check on these two arrays?
The default LOOKUP operation on unordered arrays is not terribly
efficient, as it always searches all defined elements whether used or
not.
You can increase the efficiency by limiting the number of elements
searched to only those used by filling the array from the back to the
front, then specifing the index of the first significant entry on the
LOOKUP operation. In other words, instead of keeping a field which
gets incremented to tell you where to insert a new value, initialize
the field to %elem( array ) then decrement it appropriately. On the
LOOKUP operation, use array(field) in factor2 instead of just the
array name. This causes the search to begin at the element specified,
which can dramatically lower the number of iterations.
HTH,
Doug
Ron wrote in message <35c99a03...@nntp.iaehv.nl>...
>
>Hello to you all,
>
>I'am using two arrays of a 1000 date fields to store the result of my
>routine "Check Date: Valid Or Not". This routine checks among the days
>of the week, some calenders, to check wether a date is valid or not.
>There for it has to do some database I/O and because it has to check
>date's for about one million records, I store the result in the above
>mentioned arrays. I check the arrays first before starting this
>routine.
>
>Still my programma is not running is fast as I want it to be ;-( !
>Now I'am wondering what's the performance impact of the LOOKUP
>operation code I use the check on these two arrays?
>
>Ron
This can dramatically speed up searches especially if you are getting a lot
of 'no hits'.
Otherwise, suggest using data base I/O. I have been experimenting with
user indexes but so far, they seem to be more effort than they are
apparently worth just to replace a lookup.
Ron wrote:
>
> Hello to you all,
>
> I'am using two arrays of a 1000 date fields to store the result of my
> routine "Check Date: Valid Or Not". This routine checks among the days
> of the week, some calenders, to check wether a date is valid or not.
> There for it has to do some database I/O and because it has to check
> date's for about one million records, I store the result in the above
> mentioned arrays. I check the arrays first before starting this
> routine.
>
> Still my programma is not running is fast as I want it to be ;-( !
> Now I'am wondering what's the performance impact of the LOOKUP
> operation code I use the check on these two arrays?
>
> Ron
--
Gernot Langle
PARAS Solutions, Inc.
http://www.parassolutions.com
mailto:gla...@parassolutions.com
In <35CC7C56...@tc.umn.edu>, on 08/08/98
at 11:27 AM, "Gernot B L ngle" <lang...@tc.umn.edu> said:
>ASAIK, If you keep the arrays sorted, lookup uses a binary search
>technique and is reasonably fast, but with unsorted arrays it uses a
>sequential method which is inherently slow.
>Ron wrote:
>>
>> Hello to you all,
>>
>> I'am using two arrays of a 1000 date fields to store the result of my
>> routine "Check Date: Valid Or Not". This routine checks among the days
>> of the week, some calenders, to check wether a date is valid or not.
>> There for it has to do some database I/O and because it has to check
>> date's for about one million records, I store the result in the above
>> mentioned arrays. I check the arrays first before starting this
>> routine.
>>
>> Still my programma is not running is fast as I want it to be ;-( !
>> Now I'am wondering what's the performance impact of the LOOKUP
>> operation code I use the check on these two arrays?
>>
>> Ron
--
-----------------------------------------------------------
boo...@ibm.net
Booth Martin
-----------------------------------------------------------
>ASAIK, If you keep the arrays sorted, lookup uses a binary search
>technique and is reasonably fast, but with unsorted arrays it uses a
>sequential method which is inherently slow.
Not so. RPG never uses a binary search, even with sorted arrays. Or,
at least it never used to before the rewrite of the compiler for ILE
RPG. It is possible IBM changed this, but I consider it unlikely.
I have never found LOOKUP to be reasonably fast, except with small
arrays.
Doug
You mean I went to all the trouble of showing the binary search
algorithm for nothin'? I can't find this fact documented anywhere. Are
you quite certain it's true?
Mike Cravitz
NEWS/400 Technical Editor
However, with a sorted array, it would certainly be possible (and much
more efficient) to implement LOOKUP utilizing a binary search algorithm
- perhaps someone at IBM in RPG compiler development could provide a
definite answer?
--
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum