[CalendarServer-changes] [8126] CalendarServer/trunk/contrib/tools/request_monitor.py

source_changes at macosforge.org source_changes at macosforge.org
Tue Sep 27 16:52:38 PDT 2011


Revision: 8126
          http://trac.macosforge.org/projects/calendarserver/changeset/8126
Author:   sagen at apple.com
Date:     2011-09-27 16:52:37 -0700 (Tue, 27 Sep 2011)
Log Message:
-----------
Clean up computation of req/sec

Modified Paths:
--------------
    CalendarServer/trunk/contrib/tools/request_monitor.py

Modified: CalendarServer/trunk/contrib/tools/request_monitor.py
===================================================================
--- CalendarServer/trunk/contrib/tools/request_monitor.py	2011-09-27 20:41:01 UTC (rev 8125)
+++ CalendarServer/trunk/contrib/tools/request_monitor.py	2011-09-27 23:52:37 UTC (rev 8126)
@@ -253,7 +253,6 @@
 
 while True:
 
-    samples = []
     currentSec = None
     currentCount = 0
     times = []
@@ -372,30 +371,10 @@
         times.sort()
         startTime = times[0]
         endTime = times[-1]
-        for logTime in times:
+        deltaTime = endTime - startTime
+        avgRequests = float(len(times)) / deltaTime.seconds
+        avg = "%.1f average requests per second" % (avgRequests,)
 
-            if currentSec is None:
-                currentCount = 0
-                currentSec = logTime
-            else:
-                currentCount += 1
-                if logTime != currentSec:
-                    samples.append(currentCount)
-                    currentCount = 0
-                    currentSec = logTime
-
-
-        if len(samples) < 3:
-            avgRequests = 0
-            avg = ""
-        else:
-            samples = samples[1:-1]
-            total = 0
-            for sample in samples:
-                total += sample
-            avgRequests = float(total) / len(samples)
-            avg = "%.1f average requests per second" % (avgRequests,)
-
         print "- " * 40
         print datetime.datetime.now().strftime("%Y/%m/%d %H:%M:%S"), 
         if enableListenQueue:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110927/79a45da1/attachment.html>


More information about the calendarserver-changes mailing list