Play safe and clear the article object internals, too (eg. mTouched).
[lhc/web/wiklou.git] / includes / ProfilerSimpleUDP.php
1 <?php
2 /**
3 * @file
4 * @ingroup Profiler
5 */
6
7 require_once(dirname(__FILE__).'/ProfilerSimple.php');
8
9 /**
10 * ProfilerSimpleUDP class, that sends out messages for 'udpprofile' daemon
11 * (the one from mediawiki/trunk/udpprofile SVN )
12 * @ingroup Profiler
13 */
14 class ProfilerSimpleUDP extends ProfilerSimple {
15 function getFunctionReport() {
16 global $wgUDPProfilerHost, $wgUDPProfilerPort;
17
18 if ( $this->mCollated['-total']['real'] < $this->mMinimumTime ) {
19 # Less than minimum, ignore
20 return;
21 }
22
23 $sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
24 $plength=0;
25 $packet="";
26 foreach ($this->mCollated as $entry=>$pfdata) {
27 $pfline=sprintf ("%s %s %d %f %f %f %f %s\n", $this->getProfileID(),"-",$pfdata['count'],
28 $pfdata['cpu'],$pfdata['cpu_sq'],$pfdata['real'],$pfdata['real_sq'],$entry);
29 $length=strlen($pfline);
30 /* printf("<!-- $pfline -->"); */
31 if ($length+$plength>1400) {
32 socket_sendto($sock,$packet,$plength,0,$wgUDPProfilerHost,$wgUDPProfilerPort);
33 $packet="";
34 $plength=0;
35 }
36 $packet.=$pfline;
37 $plength+=$length;
38 }
39 socket_sendto($sock,$packet,$plength,0x100,$wgUDPProfilerHost,$wgUDPProfilerPort);
40 }
41 }