The concept of "user" is not a well-defined primitive in Grinder. But
if we change "user" to "thread", then this is a question that has arisen
many times in this forum.
And as you know, Grinder has no built-in facility that implements thread
ramp-up. But thanks to Jython, it's not hard to roll-your-own. Below
is an outline of the way I do it. Undoubtedly others have implemented
equally good ways.
########################################################################
## At the top of your script, in the configuration portion of
your
## script, define the following dict.
########################################################################
g_INITIALDELAY = {} # def={}; {(thrMin1,thrMax1):sec1,
(thrMin2,thrMax2):sec2, ...}
########################################################################
## If you have a User Manual in your script (as I do), following
is the
## documentation to include in it.
########################################################################
# - g_INITIALDELAY:
# Amount of time (in sec.) threads delay before they start
doing their
# test runs. It is specifed as shown in the following
example:
# {(0,9):0*60, (10,19):5*60, (20,29):10*60,
(30,999):15*60}
# which means:
# threads # 0- 9 start immediately (0 delay, the default)
# threads #10-19 start at 5-min mark
# threads #20-29 start at 10-min mark
# remaining threads (if any) start at 15-min mark
# Threads in Grinder are numbered in the range
0..grinder.threads-1.
# Threads not specifed in g_INITIALDELAY have 0 delay (i.e.,
the
# default is to start immediately). It is illegal to specify
more
# delays than grinder.threads.
########################################################################
## In the implementation portion of your script, validate the
g_INITIALDELAY
## dict (to make sure the user specified legal params).
########################################################################
if not isinstance(g_INITIALDELAY, dict):
bailOut(99, lineno(), 'BAD g_INITIALDELAY!')
for delaySpec in g_INITIALDELAY.keys():
if not (isinstance(delaySpec, tuple) and len(delaySpec)==2
and \
isinstance(delaySpec[0],int) and
isinstance(delaySpec[1],int) and \
0<=delaySpec[0]<=delaySpec[1] and \
isinstance(g_INITIALDELAY[delaySpec],int) and
g_INITIALDELAY[delaySpec]>=0):
bailOut(99, lineno(), 'BAD g_INITIALDELAY!')
########################################################################
## To implement the ramp-up functionality, define a helper
vector variable,
## g_INITIALDELAYvec.
########################################################################
# Get number of grinder threads.
grinderProps = grinder.getProperties()
threadsStr = grinderProps.get('grinder.threads')
if threadsStr == None:
bailOut(99, lineno(), 'BAD grinder.threads (must be >= 1)!')
else:
numWorkerThreads = int(threadsStr)
if numWorkerThreads <= 0:
bailOut(99, lineno(), 'BAD grinder.threads (must be >=
1)!')
g_INITIALDELAYvec = []
for threadNum in range(numWorkerThreads):
g_INITIALDELAYvec.append(0)
for delaySpec in g_INITIALDELAY:
threadNumLo, threadNumHi = delaySpec[0], delaySpec[1]
if threadNumHi > numWorkerThreads:
bailOut(99, lineno(), 'BAD g_INITIALDELAY (specifies
thread number > grinder.threads)!')
for threadNum in range(threadNumLo, threadNumHi+1):
g_INITIALDELAYvec[threadNum] = g_INITIALDELAY[delaySpec]
########################################################################
## Finally, in your TestRunner.__call__(), make your threads
sleep
## before their initial runs, as follows.
########################################################################
def __call__(self):
if grinder.getRunNumber()==0:
java.lang.Thread.sleep(g_INITIALDELAYvec[grinder.getThreadNumber()]*g_th
ousand)
# Note: This sleep-time isn't counted in the Grinder
stats (which is a Good Thing).
________________________________
From: Sudhee.Dwivedi@... [mailto:Sudhee.Dwivedi@...]
Sent: Friday, May 08, 2009 8:01 AM
To: grinder-use@...
Subject: [Grinder-use] (no subject)
Hi
can i create ascenario where virtual user ramp up is variable. For e.g.
I want to start initially with 10 users. Run it for 5 mins then add 3
users again run (so total 13 users) run it for 3 mins. Add 2 users more,
run it for 5 mins and then end .
Plz reply asap
thanks and regards
Sudhee
Think before you print - save energy and paper
This email originates from Steria*. It, and any attachments, may contain
confidential information and may be subject to copyright or other
intellectual property rights. It is only for the use of the
addressee(s). You may not copy, forward, disclose, save or otherwise use
it in any way if you are not the addressee(s) or responsible for
delivery.
If you receive this email by mistake, please advise the sender and
cancel it immediately.
Steria may monitor the content of emails within its network to ensure
compliance with its policies and procedures.
Any email is susceptible to alteration and its integrity cannot be
assured. Steria shall not be liable if the message is altered, modified,
falsified, or edited.
_____________________________________________________
* Steria Limited, number 4077975;
Steria Recruitment Limited, number 1437998.
Registered in England and Wales; registered office Three Cherry Trees
Lane, Hemel Hempstead, Hertfordshire HP2 7AH
http://www.steria.co.uk <http://www.steria.co.uk/>
|