10.4. Profiling

 < Day Day Up > 

Profiling RT code is simple if you use the standalone HTTP server that comes with RT. [*] Profiling requires the following steps:

[*] Here we cover only profiling module code in lib/. To profile Mason components, use the MasonX::Profiler module, which is available on CPAN.

  1. Start the standlone HTTP server with the Perl profiling flag (-d:DProf).

  2. Run many requests that exercise the same code. This is necessary in order to ensure that the cost of simply starting up the server does not outweigh the cost of the code you want to profile.

  3. Exit cleanly, do not just abort the HTTP server process. This makes sure that the state of the Perl interpreter does not become corrupted.

The last step requires that we add a simple extra top-level Mason component, which we will call exit.html. Place this in local/html under your RT installation directory. The component should look like this:

     % exit; 

Of course, this is not something you want in a production installation, since it would let anyone abort a process with a simple HTTP request.

To start the standalone server with profiling turned on, run it as, /path/to/perl -d:DProf /path/to/standlone_httpd.

Then run the same request many times. To exit, simply call the exit.html component, which should be available via a URL of /exit.html.

When the process exits, the Perl profiler leaves behind a file tmon.out. Use the dprofpp script to see the results of the profiling in various formats.

If you have RT's development mode turned on, you may want to turn it off when profiling, as development mode adds non-trivial overhead to each request that is not present in a production environment.

     < Day Day Up > 


    RT Essentials
    RT Essentials
    ISBN: 0596006683
    EAN: 2147483647
    Year: 2005
    Pages: 166

    Similar book on Amazon

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net