summaryrefslogtreecommitdiff
path: root/includes/ProfilerSimpleUDP.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2006-10-11 18:12:39 +0000
committerPierre Schmitz <pierre@archlinux.de>2006-10-11 18:12:39 +0000
commit183851b06bd6c52f3cae5375f433da720d410447 (patch)
treea477257decbf3360127f6739c2f9d0ec57a03d39 /includes/ProfilerSimpleUDP.php
MediaWiki 1.7.1 wiederhergestellt
Diffstat (limited to 'includes/ProfilerSimpleUDP.php')
-rw-r--r--includes/ProfilerSimpleUDP.php34
1 files changed, 34 insertions, 0 deletions
diff --git a/includes/ProfilerSimpleUDP.php b/includes/ProfilerSimpleUDP.php
new file mode 100644
index 00000000..c395228b
--- /dev/null
+++ b/includes/ProfilerSimpleUDP.php
@@ -0,0 +1,34 @@
+<?php
+/* ProfilerSimpleUDP class, that sends out messages for 'udpprofile' daemon
+ (the one from wikipedia/udpprofile CVS )
+*/
+
+require_once(dirname(__FILE__).'/Profiling.php');
+require_once(dirname(__FILE__).'/ProfilerSimple.php');
+
+class ProfilerSimpleUDP extends ProfilerSimple {
+ function getFunctionReport() {
+ global $wgUDPProfilerHost;
+ global $wgUDPProfilerPort;
+ global $wgDBname;
+
+ $sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
+ $plength=0;
+ $packet="";
+ foreach ($this->mCollated as $entry=>$pfdata) {
+ $pfline=sprintf ("%s %s %d %f %f %f %f %s\n", $wgDBname,"-",$pfdata['count'],
+ $pfdata['cpu'],$pfdata['cpu_sq'],$pfdata['real'],$pfdata['real_sq'],$entry);
+ $length=strlen($pfline);
+ /* printf("<!-- $pfline -->"); */
+ if ($length+$plength>1400) {
+ socket_sendto($sock,$packet,$plength,0,$wgUDPProfilerHost,$wgUDPProfilerPort);
+ $packet="";
+ $plength=0;
+ }
+ $packet.=$pfline;
+ $plength+=$length;
+ }
+ socket_sendto($sock,$packet,$plength,0x100,$wgUDPProfilerHost,$wgUDPProfilerPort);
+ }
+}
+?>