Removed check whether memory_get_usage() exists; per manual it is always included...
[lhc/web/wiklou.git] / includes / profiler / ProfilerSimpleUDP.php
1 <?php
2 /**
3 * @file
4 * @ingroup Profiler
5 */
6
7 /**
8 * ProfilerSimpleUDP class, that sends out messages for 'udpprofile' daemon
9 * (the one from mediawiki/trunk/udpprofile SVN )
10 * @ingroup Profiler
11 */
12 class ProfilerSimpleUDP extends ProfilerSimple {
13 function getFunctionReport() {
14 global $wgUDPProfilerHost, $wgUDPProfilerPort;
15
16 if ( $this->mCollated['-total']['real'] < $this->mMinimumTime ) {
17 # Less than minimum, ignore
18 return;
19 }
20
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;
33 }
34 $packet.=$pfline;
35 $plength+=$length;
36 }
37 socket_sendto($sock,$packet,$plength,0x100,$wgUDPProfilerHost,$wgUDPProfilerPort);
38 }
39 }