[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: HTTPAPI XML parsing performance



   Michael,
   This is what I have in mind and what I would check in order to improve
   performance:
   1. Assuming that 'utag' is a long fixed-length string it might take
   more time as expected to perform the %trimr() on each 'when' statement.
   Maybe you should to the trimming before the 'select' group:   utag  =
   %trimr(uppify(tag))  ;
   2. Usually people compare the incoming path name with the expected
   value to retrieve the related elements. Comparing a string should be
   faster than scanning for a value because it is sufficient to compare
   the first letters of both values to see that the values do not match.
   However scanning requires to check all letters of the scanned item.
   3. You may also consider to trim 'path' and 'tag' before converting
   them to upper case. That should be faster, provided that the input
   parameter of uppify() is a 'varying' field:   utag  =
   uppify(%trimr(tag))  ;
   Of course the first thing that comes into our minds when talking about
   performance is I/O. There is no doubt about that to much I/Os
   significantly reduce performance and that each I/O, that we can get rid
   of, increases performance. Whereas we usually are not concerned about
   string operations, which might be completely wrong if we have to do
   lots of trim() or scan() operations on long fixed-length fields.
   Also to many realloc() operations can significantly reduce performance,
   which was a problem we had on our system.
   Regards,
   Thomas.
   ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx schrieb am 21.01.2013 17:44:44:
   > Von: michael.rushton@xxxxxxxxx
   > An: ftpapi@xxxxxxxxxxxxxxxxxxxxxx,
   > Datum: 22.01.2013 02:45
   > Betreff: HTTPAPI XML parsing performance
   > Gesendet von: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
   >
   > I have searched my mailing list for an answer to this but, alas,
   found
   > nothing. If I have overlooked an article on this, feel free to simply
   point
   > me at it.
   >
   > I am successfully extracting data from an XML file in the IFS however
   I
   > have a question concerning its performance. The IFS file itself is
   > approximately 32kb, contains around 1500 tags and takes about 12
   seconds to
   > parse. I am using Expat to do the parsing.
   >
   > OS/400 version is V5R3M0
   >
   > LIBHTTP is 1.25 Beta 1
   >
   > The STMF has a CCSID of 819 although I have tried it using 1252 with
   no
   > noticeable difference.
   >
   > Am I being overly optimistic in thinking that this should be
   processed in
   > two or three seconds ?
   >
   > Any pointers as to how I might improve the execution time or where I
   should
   > look will be gratefully received.
   >
   > *Code snippets:*
   >
   > The data structure used to store the data...
   >
   >  * DS for parsed XML file
   > D xVehData        ds                  qualified
   >  * ... Header
   > D  Token                        20A   varying
   > D  partnerCode                  20A   varying
   > D  serviceID                    20A   varying
   > D  userID                       20A   varying
   > D  password                     20A   varying
   > D  client                       20A   varying
   > D  customer                     20A   varying
   >  * ... Vehicle Master
   > D  regNumber                    20A   varying
   > D  vin                          20A   varying
   > D  firstRegDate                 10A   varying
   >
   > etc
   >
   >
   > The code used to parse the XML...
   >
   > if (http_parse_xml_stmf( ifsObj
   >                        : HTTP_XML_CALC
   >                        : *null
   >                        : %paddr(incoming)
   >                        : %addr(xVehData) ) < *zero);
   >
   >
   > // Notify user of error
   >
   > else;
   >
   > // Populate screen fields
   >
   > endif;
   >
   >
   > The "incoming" procedure has the following structure...
   >
   > upath = %trimr(uppify(path));  // Uppercase
   > utag  =        uppify(tag)  ;  // conversion
   > // Header section - - - - - - - - - - - -
   > if (%scan(@HEADER: upath) > *zero);
   >    select;
   >       when %trimr(utag) = 'TOKEN';
   >          xVehData.Token = %trimr(value);
   >       when %trimr(utag) = 'PARTNERCODE';
   >          xVehData.PartnerCode = %trimr(value);
   >       when %trimr(utag) = 'ISSERVICEID';
   >          xVehData.ServiceID = %trimr(value);
   >       when %trimr(utag) = 'USERID';
   >          xVehData.UserID = %trimr(value);
   >       when %trimr(utag) = 'PASSWORD';
   >          xVehData.Password = %trimr(value);
   >       when %trimr(utag) = 'CLIENT';
   >          xVehData.Client = %trimr(value);
   >       when %trimr(utag) = 'CUSTOMERNUM';
   >          xVehData.Customer = %trimr(value);
   >    endsl;
   >
   >
   > etc
   >
   >
   >
   >
   > ---------------------------------
   > Michael
   >
   -----------------------------------------------------------------------
   > This is the FTPAPI mailing list.  To unsubscribe, please go to:
   > [1]http://www.scottklement.com/mailman/listinfo/ftpapi
   >
   -----------------------------------------------------------------------

   --
   IMPORTANT NOTICE:
   This email is confidential, may be legally privileged, and is for the
   intended recipient only. Access, disclosure, copying, distribution, or
   reliance on any of it by anyone else is prohibited and may be a
   criminal
   offence. Please delete if obtained in error and email confirmation to
   the sender.

References

   1. http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------