MediaWiki
REL1_19
|
00001 <?php 00012 class ProfilerSimpleUDP extends ProfilerSimple { 00013 public function logData() { 00014 global $wgUDPProfilerHost, $wgUDPProfilerPort; 00015 00016 $this->close(); 00017 00018 if ( isset( $this->mCollated['-total'] ) && $this->mCollated['-total']['real'] < $this->mMinimumTime ) { 00019 # Less than minimum, ignore 00020 return; 00021 } 00022 00023 if ( !MWInit::functionExists( 'socket_create' ) ) { 00024 # Sockets are not enabled 00025 return; 00026 } 00027 00028 $sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); 00029 $plength = 0; 00030 $packet = ""; 00031 foreach ( $this->mCollated as $entry => $pfdata ) { 00032 if( !isset($pfdata['count']) 00033 || !isset( $pfdata['cpu'] ) 00034 || !isset( $pfdata['cpu_sq'] ) 00035 || !isset( $pfdata['real'] ) 00036 || !isset( $pfdata['real_sq'] ) ) { 00037 continue; 00038 } 00039 $pfline = sprintf( "%s %s %d %f %f %f %f %s\n", $this->getProfileID(), "-", $pfdata['count'], 00040 $pfdata['cpu'], $pfdata['cpu_sq'], $pfdata['real'], $pfdata['real_sq'], $entry); 00041 $length = strlen( $pfline ); 00042 /* printf("<!-- $pfline -->"); */ 00043 if ( $length + $plength > 1400 ) { 00044 socket_sendto( $sock, $packet, $plength, 0, $wgUDPProfilerHost, $wgUDPProfilerPort ); 00045 $packet = ""; 00046 $plength = 0; 00047 } 00048 $packet .= $pfline; 00049 $plength += $length; 00050 } 00051 socket_sendto( $sock, $packet, $plength, 0x100, $wgUDPProfilerHost, $wgUDPProfilerPort ); 00052 } 00053 }