minor refactoring

This commit is contained in:
Miroslav Stampar 2011-02-22 12:54:22 +00:00
parent 17c39fe231
commit dcad5410fe
2 changed files with 9 additions and 2 deletions

View File

@ -2379,3 +2379,10 @@ def intersect(valueA, valueB):
retVal = [val for val in arrayizeValue(valueA) if val in arrayizeValue(valueB)] retVal = [val for val in arrayizeValue(valueA) if val in arrayizeValue(valueB)]
return retVal return retVal
def cpuThrottle(value):
"""
Does a CPU throttling for a lesser CPU consumption
"""
delay = 0.00001 * (value ** 2)
time.sleep(delay)

View File

@ -20,6 +20,7 @@ from lib.core.agent import agent
from lib.core.common import average from lib.core.common import average
from lib.core.common import calculateDeltaSeconds from lib.core.common import calculateDeltaSeconds
from lib.core.common import clearConsoleLine from lib.core.common import clearConsoleLine
from lib.core.common import cpuThrottle
from lib.core.common import getCurrentThreadData from lib.core.common import getCurrentThreadData
from lib.core.common import getFilteredPageContent from lib.core.common import getFilteredPageContent
from lib.core.common import unicodeToSafeHTMLValue from lib.core.common import unicodeToSafeHTMLValue
@ -70,8 +71,7 @@ class Connect:
if conf.delay is not None and isinstance(conf.delay, (int, float)) and conf.delay > 0: if conf.delay is not None and isinstance(conf.delay, (int, float)) and conf.delay > 0:
time.sleep(conf.delay) time.sleep(conf.delay)
elif conf.cpuThrottle: elif conf.cpuThrottle:
delay = 0.00001 * (conf.cpuThrottle ** 2) cpuThrottle(conf.cpuThrottle)
time.sleep(delay)
threadData = getCurrentThreadData() threadData = getCurrentThreadData()
threadData.lastRequestUID += 1 threadData.lastRequestUID += 1