|
> -----Original Message----- > From: rpg400-l-bounces@xxxxxxxxxxxx > [mailto:rpg400-l-bounces@xxxxxxxxxxxx]On Behalf Of Joel Cochran > Sent: Wednesday, June 15, 2005 9:59 AM > To: RPG programming on the AS400 / iSeries > Subject: RE: TEST Date in free form > > > > Let's say we encounter a date that is neither *USA or *USA0: these are > the operations that must happen to finally resolve the error: > > 1. TEST(DE) the format for *USA > 2. Check for an error condition. (FOUND) > 3. TEST(DE) the format for *USA0 > 4. Check for an error condition. (FOUND) > 5. Assign default value. > > With monitor, you have the following: > 1. Try to assign as *USA. (FAILS) > 2. Try to assign as *USA0. (FAILS) > 3. Assign default value. > > A 5-3 ratio! For 100,000 records, even if all of them were poorly > formatted, that's 500,000 operations vs. 300,000. > > Now assume a record with valid *USA: > > 1. TEST(DE) the format for *USA > 2. Check for an error condition. (NOT FOUND) > 3. Assign *USA value. > > vs. > > 1. Assign *USA value. > > Now it's a 3-to-1 ratio! > > Now assume 100,000 records with 75,000 bad formats and 25,000 > with *USA: > > TEST(DE): > 5 x 75,000 = 375,000 > 3 X 25,000 = 75,000 > TOTAL = 450,000 Operations. > > MONITOR: > 3 x 75,000 = 225,000 > 1 x 25,000 = 25,000 > TOTAL = 250,000 Operations. > > So even with 75% bad formats, you still do much much better > with MONITOR > than TEST(DE). > Joel, While I agree with your number of operations calcs, if you're really looking at performance you need to take into account the amount of time each operation takes. Five quick operations could easily beat 3 long ones. As I understand it, one of the most expensive operations is throwing an exception (in any language). Thus, if you expect a lot of invalid data, it makes sense to do the test (DE) before trying the conversion. In a quick test, doing 100 test(de) on a bad date took .04s whereas using monitor around the attempted conversion of the bad date took .145s. That's over a 300% performance decrease. HTH, Charles Wilt -- iSeries Systems Administrator / Developer Mitsubishi Electric Automotive America ph: 513-573-4343 fax: 513-398-1121
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.