8 * ProfilerSimpleUDP class, that sends out messages for 'udpprofile' daemon
9 * (the one from mediawiki/trunk/udpprofile SVN )
12 class ProfilerSimpleUDP
extends ProfilerSimple
{
13 public function logData() {
14 global $wgUDPProfilerHost, $wgUDPProfilerPort;
18 if ( isset( $this->mCollated
['-total'] ) && $this->mCollated
['-total']['real'] < $this->mMinimumTime
) {
19 # Less than minimum, ignore
23 if ( !MWInit
::functionExists( 'socket_create' ) ) {
24 # Sockets are not enabled
28 $sock = socket_create(AF_INET
, SOCK_DGRAM
, SOL_UDP
);
31 foreach ( $this->mCollated
as $entry => $pfdata ) {
32 if( !isset($pfdata['count'])
33 ||
!isset( $pfdata['cpu'] )
34 ||
!isset( $pfdata['cpu_sq'] )
35 ||
!isset( $pfdata['real'] )
36 ||
!isset( $pfdata['real_sq'] ) ) {
39 $pfline = sprintf( "%s %s %d %f %f %f %f %s\n", $this->getProfileID(), "-", $pfdata['count'],
40 $pfdata['cpu'], $pfdata['cpu_sq'], $pfdata['real'], $pfdata['real_sq'], $entry);
41 $length = strlen( $pfline );
42 /* printf("<!-- $pfline -->"); */
43 if ( $length +
$plength > 1400 ) {
44 socket_sendto( $sock, $packet, $plength, 0, $wgUDPProfilerHost, $wgUDPProfilerPort );
51 socket_sendto( $sock, $packet, $plength, 0x100, $wgUDPProfilerHost, $wgUDPProfilerPort );