In message <[email protected]>,
Risto Vaarandi writes:

>On 03/21/2012 10:05 PM, John P. Rouillard wrote:
>> Is there a way in perl to have the compile of the script remove lines?
>> Sort of like how python optimizes out __debug__ lines if optimization
>> is requested. That would make the profiler have 0 effect unless
>> enabled since it would not show up in the perl bytecode.
>>
>> Maybe a perl source filter (ugly but...) could work? It may require
>> a second source file though.
>>
>> http://perldoc.perl.org/perlfilter.html look for
>>
>>    USING CONTEXT: THE DEBUG FILTER
>>
>> for an idea.
>
>Here the problem is that SEC supports altering command line options at 
>runtime. Through the resource file, it is possible to introduce new 
>options, and remove or change existing options. Of course, the debug 
>option might be defined as an exception which can not be changed, but 
>that would make the perl source filter even less elegant :(

I do this in a couple of my programs. Profiling is triggered by an
environment variable, but enabled using --profiling.

I parse/collect all the options and if I process --profiling in the
option list, I remove it from the option list and re-exec the process
using the command line for all options and setting the PROFILING
variable.  In the script the profiling variable is checked right at
the top and activates the profiler. So I get profiling for the whole
thing except the code that actually triggers the profiler.

Alternatively we could just say: "To activate profiling, set the
environment variable SECPROFILE before starting SEC." 8-).

Since it is (crosses fingers) unlikely that anybody would want to run
this in production with profiling enabled (due to the performance
hit), using an enironment variable directly could be a workable
alternative.

--
                                -- rouilj
John Rouillard
===========================================================================
My employers don't acknowledge my existence much less my opinions.

------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
Simple-evcorr-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/simple-evcorr-users

Reply via email to