Skip to content

Instantly share code, notes, and snippets.

@kvalle
Created March 16, 2012 17:33
Show Gist options
  • Save kvalle/2051308 to your computer and use it in GitHub Desktop.
Save kvalle/2051308 to your computer and use it in GitHub Desktop.
Decorator for Grinder thread-rampup
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