× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



> Independently of the number of bytes to be returned, the call of the
> procedure is very slow (time job running was 19 seconds). When I define the
> return field like the input field with 255 bytes the call is faster (runtime
> only 1 second).
>
> Why that? I would expect, that only characters needed and length information
> are copied to the calling procedure. Not the hole storage area.

When returning a 64k string by VALUE, here's what your procedure has to
do:
    1) Address of input parameter is copied from caller to subproc.
    2) 65537 bytes of memory allocated for #RtnStr variable.
    3) up to 255 bytes of data are copied from $InpStr to #RtnStr
    4) 65537 bytes of data are copied from #RtnStr to the caller's #str1
    5) The memory allocated for #RtnStr is deallocated

The slowest point will be step 4, where the return value is copied, since
over 64k of data needs to be copied.

Instead, I would do it this way:

     P TSTPRC2         B
     D TSTPRC2         PI
     D   $InpStr                    255    varying const
     D   #RtnStr                  65535    varying options(*varsize)
     D   RtnStrSize                  10I 0 value

     c                   eval      RtnStrSize = RtnStrSize - 2

     c                   if        %len($InpStr) > RtnStrSize
     c                   eval      #RtnStr = %subst($InpStr:1:RtnStrSize)
     c                   else
     c                   eval      #RtnStr = $InpStr
     c                   endif

     c                   return
     P                 E

When you call it, do it like this:

     callp TSTPRC2(str2: str1: %size(str1))

Using this method allows you to use any size of data, just like your
solution did.

However, the only data that need to be copied back & forth is the ADDRESS
of the two strings (16 bytes each) plus the 4 bytes for the size.  Total of
36 bytes.

That should perform MUCH better than returning a 65537 byte variable.

Hope that helps...

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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.