r32045 committed from wrong working branch. Revert and commit the one I wanted.
[mediawiki.git] / includes / ProfilerSimpleUDP.php
blob7d2f7e21b3b9a1f6cb27edbe21d245451c58d389
1 <?php
3 require_once(dirname(__FILE__).'/Profiler.php');
4 require_once(dirname(__FILE__).'/ProfilerSimple.php');
6 /**
7 * ProfilerSimpleUDP class, that sends out messages for 'udpprofile' daemon
8 * (the one from mediawiki/trunk/udpprofile SVN )
9 * @addtogroup Profiler
11 class ProfilerSimpleUDP extends ProfilerSimple {
12 function getFunctionReport() {
13 global $wgUDPProfilerHost;
14 global $wgUDPProfilerPort;
16 if ( $this->mCollated['-total']['real'] < $this->mMinimumTime ) {
17 # Less than minimum, ignore
18 return;
21 $sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
22 $plength=0;
23 $packet="";
24 foreach ($this->mCollated as $entry=>$pfdata) {
25 $pfline=sprintf ("%s %s %d %f %f %f %f %s\n", $this->getProfileID(),"-",$pfdata['count'],
26 $pfdata['cpu'],$pfdata['cpu_sq'],$pfdata['real'],$pfdata['real_sq'],$entry);
27 $length=strlen($pfline);
28 /* printf("<!-- $pfline -->"); */
29 if ($length+$plength>1400) {
30 socket_sendto($sock,$packet,$plength,0,$wgUDPProfilerHost,$wgUDPProfilerPort);
31 $packet="";
32 $plength=0;
34 $packet.=$pfline;
35 $plength+=$length;
37 socket_sendto($sock,$packet,$plength,0x100,$wgUDPProfilerHost,$wgUDPProfilerPort);