Consolidated web initialisation code into includes/WebStart.php. Moved profiling...
[lhc/web/wiklou.git] / includes / ProfilerSimpleUDP.php
1 <?php
2 /* ProfilerSimpleUDP class, that sends out messages for 'udpprofile' daemon
3 (the one from wikipedia/udpprofile CVS )
4 */
5
6 require_once(dirname(__FILE__).'/Profiler.php');
7 require_once(dirname(__FILE__).'/ProfilerSimple.php');
8
9 class ProfilerSimpleUDP extends ProfilerSimple {
10 function getFunctionReport() {
11 global $wgUDPProfilerHost;
12 global $wgUDPProfilerPort;
13 global $wgDBname;
14
15 $sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
16 $plength=0;
17 $packet="";
18 foreach ($this->mCollated as $entry=>$pfdata) {
19 $pfline=sprintf ("%s %s %d %f %f %f %f %s\n", $wgDBname,"-",$pfdata['count'],
20 $pfdata['cpu'],$pfdata['cpu_sq'],$pfdata['real'],$pfdata['real_sq'],$entry);
21 $length=strlen($pfline);
22 /* printf("<!-- $pfline -->"); */
23 if ($length+$plength>1400) {
24 socket_sendto($sock,$packet,$plength,0,$wgUDPProfilerHost,$wgUDPProfilerPort);
25 $packet="";
26 $plength=0;
27 }
28 $packet.=$pfline;
29 $plength+=$length;
30 }
31 socket_sendto($sock,$packet,$plength,0x100,$wgUDPProfilerHost,$wgUDPProfilerPort);
32 }
33 }
34 ?>