[CalendarServer-changes] [6918] CalendarServer/trunk/contrib/performance

source_changes at macosforge.org source_changes at macosforge.org
Fri Feb 11 09:46:11 PST 2011


Revision: 6918
          http://trac.macosforge.org/projects/calendarserver/changeset/6918
Author:   exarkun at twistedmatrix.com
Date:     2011-02-11 09:46:10 -0800 (Fri, 11 Feb 2011)
Log Message:
-----------
Allow the scaling parameter to be configured per-benchmark with command line options.

Modified Paths:
--------------
    CalendarServer/trunk/contrib/performance/benchmark.py
    CalendarServer/trunk/contrib/performance/test_benchmark.py

Modified: CalendarServer/trunk/contrib/performance/benchmark.py
===================================================================
--- CalendarServer/trunk/contrib/performance/benchmark.py	2011-02-10 19:51:57 UTC (rev 6917)
+++ CalendarServer/trunk/contrib/performance/benchmark.py	2011-02-11 17:46:10 UTC (rev 6918)
@@ -321,14 +321,14 @@
 
 
 @inlineCallbacks
-def benchmark(host, port, pids, label, benchmarks):
-    parameters = [1, 9, 81]
+def benchmark(host, port, pids, label, scalingParameters, benchmarks):
     samples = 200
 
     statistics = {}
 
     for (name, measure) in benchmarks:
         statistics[name] = {}
+        parameters = scalingParameters.get(name, [1, 9, 81])
         for p in parameters:
             print '%s, parameter=%s' % (name, p)
             dtrace = DTraceCollector("io_measure.d", pids)
@@ -368,6 +368,11 @@
         ('debug', None, 'Enable various debugging helpers'),
         ]
 
+    def __init__(self):
+        Options.__init__(self)
+        self['parameters'] = {}
+
+
     def _selectBenchmarks(self, benchmarks):
         """
         Select the benchmarks to run, based on those named and on the
@@ -392,12 +397,26 @@
         return benchmarks
 
 
+    def opt_parameters(self, which):
+        """
+        Specify the scaling parameters for a particular benchmark.
+        The format of the value is <benchmark>:<value>,...,<value>.
+        The given benchmark will be run with a scaling parameter set
+        to each of the given values.  This option may be specified
+        multiple times to specify parameters for multiple benchmarks.
+        """
+        benchmark, values = which.split(':')
+        values = map(int, values.split(','))
+        self['parameters'][benchmark] = values
+
+
     def parseArgs(self, *benchmarks):
         if not benchmarks:
             raise UsageError("Specify at least one benchmark")
         self['benchmarks'] = self._selectBenchmarks(list(benchmarks))
 
 
+
 def whichPIDs(source, conf):
     """
     Return a list of PIDs to dtrace.
@@ -433,6 +452,7 @@
 
     d = benchmark(
         options['host'], options['port'], pids, options['label'],
+        options['parameters'],
         [(arg, namedAny(arg).measure) for arg in options['benchmarks']])
     d.addErrback(err)
     reactor.callWhenRunning(d.addCallback, lambda ign: reactor.stop())

Modified: CalendarServer/trunk/contrib/performance/test_benchmark.py
===================================================================
--- CalendarServer/trunk/contrib/performance/test_benchmark.py	2011-02-10 19:51:57 UTC (rev 6917)
+++ CalendarServer/trunk/contrib/performance/test_benchmark.py	2011-02-11 17:46:10 UTC (rev 6918)
@@ -35,6 +35,17 @@
         self.options = BenchmarkOptions()
 
 
+    def test_parameters(self):
+        """
+        The I{--parameters} option can be specified multiple time and
+        each time specifies the parameters for a particular benchmark
+        as a comma separated list of integers.
+        """
+        self.options.parseOptions(["--parameters", "foo:1,10,100", "foo"])
+        self.assertEquals(
+            self.options['parameters'], {"foo": [1, 10, 100]})
+
+
     def test_filterBenchmarksWithoutDistribution(self):
         """
         If neither I{--hosts-count} nor I{--host-index} are supplied,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110211/1b26e91f/attachment.html>


More information about the calendarserver-changes mailing list