On 01/10/2009, at 10:51 AM, CRPence wrote:
FWiW [although you already know this :-)]: The search for the
program could be made easier by using [i.e. deferring to the logic
in] the QMHSNDPM API instead,
Just finalising this thread.
Yes, I did know that :) but dropped it from my consideration for the
same reason as I dropped materialising the call stack. Message
handling is a very useful and powerful function but it's also quite
slow. I did not have empirical data to support that--just experience
and "gut feel".
So to close things off properly I wrote three trivial test programs
this morning just to see the timing differences. One uses my original
getppid() idea, one uses Dave McKenzie's call stack suggestion, and
the final one uses Chuck Pence's send message suggestion.
I ran the code from within QSHELL via symbolic links. I ran each test
multiple times and took the best time. Here are the test results from
a model 170-2291 running VRM510.
time_getppid 632 microseconds
time_sndpmsg 1624 microseconds
time_callstk 13312 microseconds
If anyone wants to see the test code just let me know.
The call stack test could be sped up by declaring sufficient storage
for 5 entries and only do a single call to retrieve just that many
entries "knowing" the desired entry is probably the 3rd one in the
stack but it still wouldn't be as fast as the getppid() version.
Given that the point of this code was to determine whether a program
is running in QSHELL and that is likely to be invoked only once on any
given call then any of these methods would suffice. The getppid()
method was less lines of code and faster so I'm happy that's the one I
implemented. My "gut" was right--so pleased it can do more than make
noises and bad smells.
Regards,
Simon Coulter.
--------------------------------------------------------------------
FlyByNight Software OS/400, i5/OS Technical Specialists
http://www.flybynight.com.au/
Phone: +61 2 6657 8251 Mobile: +61 0411 091 400 /"\
Fax: +61 2 6657 8251 \ /
X
ASCII Ribbon campaign against HTML E-Mail / \
--------------------------------------------------------------------
As an Amazon Associate we earn from qualifying purchases.