@@ -1273,26 +1273,30 @@ def readCachedFileContent(filename, mode='rb'):
12731273
12741274def readXmlFile (xmlFile ):
12751275 checkFile (xmlFile )
1276+
12761277 xfile = codecs .open (xmlFile , 'r' , conf .dataEncoding )
12771278 retVal = minidom .parse (xfile ).documentElement
1279+
12781280 xfile .close ()
1281+
12791282 return retVal
12801283
12811284def stdev (values ):
12821285 """
12831286 Computes standard deviation of a list of numbers.
12841287 Reference: http://www.goldb.org/corestats.html
12851288 """
1289+
12861290 if not values or len (values ) < 2 :
12871291 return None
12881292
1289- sum = 0.0
1293+ summa = 0.0
12901294 avg = average (values )
12911295
12921296 for value in values :
1293- sum += pow (value - avg , 2 )
1297+ summa += pow (value - avg , 2 )
12941298
1295- return sqrt (sum / (len (values ) - 1 ))
1299+ return sqrt (summa / (len (values ) - 1 ))
12961300
12971301def average (values ):
12981302 """
@@ -1544,11 +1548,13 @@ def wasLastRequestDelayed():
15441548 # affected response times should be inside +-7*stdev([normal response times])
15451549 # (Math reference: http://www.answers.com/topic/standard-deviation)
15461550 deviation = stdev (kb .responseTimes )
1551+
15471552 if deviation :
15481553 if len (kb .responseTimes ) < MIN_TIME_RESPONSES :
1549- warnMsg = "time based standard deviation method used "
1550- warnMsg += "on a model with less than %d response times" % MIN_TIME_RESPONSES
1554+ warnMsg = "time- based standard deviation method used on a model "
1555+ warnMsg += "with less than %d response times" % MIN_TIME_RESPONSES
15511556 logger .warn (warnMsg )
1557+
15521558 return (kb .lastQueryDuration >= average (kb .responseTimes ) + 7 * deviation )
15531559 else :
15541560 return kb .lastQueryDuration - conf .timeSec
0 commit comments