views:

29

answers:

1

I want to time how long it takes the server to build a MediaWiki article. That is, the start time will be as close as possible to the time the server receives the request (not the time the client issues request). The end time will be when the server sends the page (again, not when the client receives the page).

Is there any Apache function I can access from PHP that gives me the time it took for the server to build the page?

Is there a MediaWiki hook that I can use to determine the static server time as early in the article-building process as possible? This looks promising but is for a future version of MediaWiki. I know I can determine the server time at the end of page creation. With those two times, I can generate a delta.

Thanks.

==Appended=== I've just discovered "mod_headers" (http://prefetch.net/blog/index.php/2007/01/02/measuring-apache-request-processing-time/) and its ability to create a header with the time it took to serve the request, in microseconds. However, I do not know how I could use that information since javascript cannot read it. I would love to be able to send it back to my server via AJAX and log it.

A: 

This information is embedded in every page MediaWiki generates - look for something like:

Served in 0.770 secs

in the HTML source. Is this not what you're looking for?

Joshua C. Lerner
Ah... good point. I'll need to figure out how I can grab that number so I can log it. Right now, in the "OutputPageBeforeHTML" hook, I calculate the difference between current time and $_SERVER['REQUEST_TIME']. That gives me more of the actual Apache time, but at a dismal resolution of seconds (instead of milli or micro).
Chad
While not an entirely accurate depiction of total server time, I am now using "global $wgRequestTime" to calculate the time it takes MediaWiki to build the page. Thanks for the pointer.
Chad