Home | Trees | Indices | Help |
---|
|
1 from inca.Reporter import Reporter 24 """PerformanceReporter - Convenience module for performance-related 5 reporters:: 6 7 from inca.PerformanceReporter import PerformanceReporter, PerformanceBenchmark 8 performance = PerformanceReporter( 9 name = 'My performance reporter', 10 version = 1, 11 description = 'Measures host performance', 12 url = 'http://inca.sdsc.edu', 13 measurement_name = 'host performance' 14 ) 15 ... 16 benchmark = PerformanceBenchmark() 17 benchmark.addParameter('num_cpus', 16) 18 benchmark.addStatistic('bandwidth', 10, 'Mb/s') 19 performance.addBenchmark('sample', benchmark) 20 reporter.printReport() 21 22 Module for writing performance related reporters. A performance reporter 23 has one or more benchmarks. Each benchmark has one or more statistics 24 (i.e., results) and can further be described with one or more parameters. 25 For example:: 26 27 <performance> 28 <ID>some_id</ID> 29 <benchmark> 30 <ID>sample</ID> 31 <parameters> 32 <ID>parameters</ID> 33 <parameter> 34 <ID>num_cpus</ID> 35 <value>16</value> 36 </parameter> 37 </parameters> 38 <statistics> 39 <ID>statistics</ID> 40 <statistic> 41 <ID>bandwidth</ID> 42 <value>10</value> 43 <units>Mb/s</units> 44 </statistic> 45 </statistics> 46 </benchmark> 47 </performance> 48 49 By default, the exit status of the reporter will be set to true (i.e., 50 success). 51 """ 5213754 """Class constructor that returns a new PerformanceReporter object. The 55 constructor supports the following parameter in addition to those 56 supported by Reporter:: 57 58 measurement_name 59 the name of the performance metric measured by the reporter; 60 default ''. 61 """ 62 name = '' 63 if attrs.has_key('measurement_name'): 64 name = attrs['measurement_name'] 65 del attrs['measurement_name'] 66 Reporter.__init__(self, **attrs) 67 self.measurement_name = name 68 self.benchmark = {} 69 self.addDependency('inca.PerformanceReporter')7072 """Add a benchmark to the reporter. benchmark is an object of type 73 PerformanceBenchmark. name identifies the benchmark. 74 """ 75 self.benchmark[name] = benchmark7678 """A convenience that combines the allocation of a benchmark and its 79 addition to the reporter. 80 """ 81 benchmark = PerformanceBenchmark() 82 self.addBenchmark(name, benchmark) 83 return benchmark8486 """Returns the name of the performance metric measured by the reporter.""" 87 return self.measurement_name8890 """Constructs and returns the body of the reporter.""" 91 idXml = self.xmlElement('ID', 1, self.getMeasurementName()) 92 benchmarkXmls = [] 93 paramsXml = None 94 for name in self.benchmark.keys(): 95 benchmark = self.benchmark[name] 96 bidXml = self.xmlElement('ID', 1, name) 97 paramXmls = [] 98 statXmls = [] 99 params = benchmark.parameterNames() 100 params.sort() 101 for param in params: 102 (value, units) = benchmark.getParameter(param) 103 pidXml = self.xmlElement('ID', 1, param) 104 valueXml = self.xmlElement('value', 1, value); 105 unitsXml = None 106 if units != None: 107 unitsXml = self.xmlElement('units', 1, units) 108 paramXmls.append( 109 self.xmlElement('parameter', 0, pidXml, valueXml, unitsXml) 110 ) 111 paramsXml = None 112 if len(paramXmls) > 0: 113 paramsXml = self.xmlElement('parameters', 0, *paramXmls) 114 stats = benchmark.statisticNames() 115 stats.sort() 116 for stat in stats: 117 (value, units) = benchmark.getStatistic(stat); 118 sidXml = self.xmlElement('ID', 1, stat) 119 valueXml = self.xmlElement('value', 1, value) 120 unitsXml = None 121 if units != None: 122 unitsXml = self.xmlElement('units', 1, units) 123 statXmls.append( 124 self.xmlElement('statistic', 0, sidXml, valueXml, unitsXml) 125 ) 126 statsXml = None 127 if len(statXmls) > 0: 128 statsXml = self.xmlElement('statistics', 0, *statXmls) 129 benchmarkXmls.append( 130 self.xmlElement('benchmark', 0, bidXml, paramsXml, statsXml) 131 ) 132 return self.xmlElement('performance', 0, idXml, *benchmarkXmls);133139 """PerformanceBenchmark - Convenience class for managing a benchmark entry 140 141 Convenience class for the PerformanceReporter module. Manages a single 142 benchmark entry. 143 """ 144181146 """Class constructor that returns a new PerformanceBenchmark object.""" 147 self.parameters = {} 148 self.statistics = {}149151 if not self.parameters.has_key(name): 152 return None 153 param = self.parameters[name] 154 return (param['value'], param['units'])155157 if not self.statistics.has_key(name): 158 return None 159 stat = self.statistics[name] 160 return (stat['value'], stat['units'])161 164166 """Sets a parameter that was used to obtain the benchmark. name is a 167 unique identifier for this parameter and value its value. The optional 168 units describes a scalar value (e.g., Gb/s, secs, etc.). 169 """ 170 self.parameters[name] = {'value' : value, 'units' : units}171173 """Sets a statistic that was obtained for the benchmark. name is a unique 174 identifier for this parameter and value its value. The optional units 175 describes a scalar value (e.g., Gb/s, secs, etc.). 176 """ 177 self.statistics[name] = {'value' : value, 'units' : units}178
Home | Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Fri Aug 21 14:47:16 2009 | http://epydoc.sourceforge.net |