Hello,
I'd like to measure the time taken to execute each particular hit to cgi::app and display the result.
My thoughts on how to implement this are roughly:
* get the time $T1 in cgiprerun - store in $self * get the time $T2 in cgipostrun and compute the difference * output the result as a template param. (is my output out already?)
Hi Fred,
The cgiapp_init stage is the first to be executed, so that is probably a more accurate place to start timing than cgiapp_prerun.
the cgiapp_postrun stage will work, but the template is already parsed and flattened into an HTML page at that stage, so you will have to do a simple search and replace to get the time into the HTML. Regardless of that, this method will not be very accurate...
You should note that you will not get any of the startup costs like loading perl and all the required modules if you use the above methods (if you are running under mod_perl that is negligable anyway, but under CGI it will probably be most of the script execution time).
If you want this based on the time the script started, then you can look at the perl special variable $^T. However, that is in seconds, and I guess you may want more precision than that.
If you are using Apache, you can log the time used to serve the request in the access_log file using the %T variable in the LogFormat directive. This doesn't get it into the page, but does track it for you if that is all you are looking for. If you were using Apache2, you could use mod_perl2 to write a simple filter that filtered the outgoing HTML and placed the time used into the page that way (a simple s/PLACE_REQUEST_TIME_HERE/$request_time/ over the HTML would do it as long as you added the string PLACE_REQUEST_TIME_HERE in the HTML wherever you want the request time to appear. You could try either to capture the value that Apache places in the log file, or write another simple Handler that runs very early and places the start time in an Apache Note to be picked up by your outbound Filter.
There are other methods as well, it all really depends on how accurate you want this to be.
Cheers,
Cees
--------------------------------------------------------------------- Web Archive: http://www.mail-archive.com/[EMAIL PROTECTED]/ http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2 To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
