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