Re: Compiling a Module
- To: mathgroup at smc.vnet.net
- Subject: [mg15877] Re: Compiling a Module
- From: sidles at u.washington.edu (John A. Sidles)
- Date: Wed, 17 Feb 1999 23:33:32 -0500
- Organization: University of Washington, Seattle
- References: <79m6bv$3a1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Klamser <Klamser at t-online.de> wrote:
>Can anyone tell me, why compiling a module saves no time during
>execution?
It all depends on whether the module compiles wholly,
largely, or not at all to "Op Codes".
To test this, you can check your compiled modules with the
following simple utility:
myFunctionIsOpCode[x_] := Apply[List,x][[3]]//
Flatten//
VectorQ[#,NumberQ]&
When speed is important, it is well worth tweaking your modules
so that the above function returns "True".
This tweaking is more of an art than a science, for me anyway.
When a compiled function returns "False", I examine the compiled
code (using "FullForm") for clues as to which elements the
compiler is unable to parse into op-codes. Often, these are
harmless. For example, Print[...] is not compiled as an
opcodes, but who cares? So long as Print[] is used only to
generate occasional status messages.