Created
March 16, 2012 17:33
-
-
Save kvalle/2051308 to your computer and use it in GitHub Desktop.
Decorator for Grinder thread-rampup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from net.grinder.script.Grinder import grinder | |
def thread_rampup(interval): | |
"""Decorator for waking grinder threads incrementally. | |
Input argument `interval` determines time in ms between wakeup of each thread. | |
Usage: | |
class TestRunner: | |
@thread_rampup(3000) | |
def __call__(self): | |
# do some testing | |
""" | |
def decorator(fn): | |
def wrapper(*args, **kwargs): | |
if grinder.runNumber == 0: | |
sleepTime = grinder.threadNumber * interval | |
grinder.sleep(sleepTime, 0) | |
return fn(*args, **kwargs) | |
return wrapper | |
return decorator |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment