Open Question: Introducing a seed value to the random number generator in LR

25 views
Skip to first unread message

James Pulley

unread,
Mar 20, 2011, 10:04:35 AM3/20/11
to lr-loa...@googlegroups.com, LoadR...@yahoogroups.com

This question is designed to provoke curiosity:  A response is not required.

A key factor in testing is repeatability.  To support this LR supports the introduction of a random seed value for the random number generator.   Where would you look the change the random seed value for your load generators?

James Pulley, http://www.loadrunnerbythehour.com/PricingMatrix

Floris Kraak

unread,
Mar 21, 2011, 4:53:30 AM3/21/11
to lr-loa...@googlegroups.com, James Pulley, LoadR...@yahoogroups.com
On Sun, Mar 20, 2011 at 3:04 PM, James Pulley
<loadrunn...@jamespulley.com> wrote:
>
> A key factor in testing is repeatability.  To support this LR supports the
> introduction of a random seed value for the random number generator.   Where
> would you look the change the random seed value for your load generators?
>

Interesting question. You are talking about the srand() function, of course.

Normally, I try to ensure that the seed is unique, rather than
repeatably the same.

If more than one virtual user uses the same seed there is a risk that
both users will use exactly the same random values for their actions,
causing unwanted synchronisation of otherwise supposed-to-be-unique
actions. So the seed is usually calculated taking the vuser id and
virtual user group name into account.

As for repeatability between tests though - normally I simply trust
that the law of big numbers makes sure that on average the performed
set of actions is roughly the same. Making the test exactly repeatable
with many users is normally not an objective.
Therefore I use both a timestamp (of the current time) and the output
of the rand() function to add more entropy to the seed.

The resulting initialisation code can be found here:
https://github.com/randakar/y-lib/blob/master/y_loadrunner_utils.c#L58

(Note that I am open to improvements to this one - this code could
definitely be better)


I see where you are coming from with the repeatability argument
though. When you are dealing with tests that show intermittent, hard
to repeat error conditions making your test capable of performing
exactly the same set of steps with exactly the same test data each
time certainly should make life easier.


Regards,
Floris
---
'Many people asked me if I was afraid to fly and implied that I should
have stayed home, close to family and friends. I replied that if I had
stayed home, the terrorists would have won.

Unfortunately, my government does not agree with my definition of
winning. They think that living in fear and trying desperately to keep
us all 100% safe while flying is the most effective way to fight
terrorism. It reminds me of a boss that told me he liked it when
people lived in fear of being fired, they worked harder. I told him
being fired held no fear for me. When you live in fear, you do
irrational things - like sending millions of people's shoes through an
xray scanner every day.'
   -- Stormy Peters

James Pulley

unread,
Mar 21, 2011, 7:04:47 AM3/21/11
to lr-loa...@googlegroups.com
There is a location in the controller where you can manually set a seed
value. The goal of open questions is to cause readers to be curious and to
find out where to find the answer by eliminating items which do not fit on
the natural path to finding an answer....or part of the Socratic method of
education.

Implicit in this question is the understanding of a random seed, where and
why they [may|may not] be useful.

--
You received this message because you are subscribed to the Google
"LoadRunner" group.
To post to this group, send email to LR-Loa...@googlegroups.com
To unsubscribe from this group, send email to
LR-LoadRunne...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/LR-LoadRunner?hl=en

Floris Kraak

unread,
Mar 21, 2011, 7:25:32 AM3/21/11
to lr-loa...@googlegroups.com, James Pulley
On Mon, Mar 21, 2011 at 12:04 PM, James Pulley
<loadrunn...@jamespulley.com> wrote:
> There is a location in the controller where you can manually set a seed
> value. The goal of open questions is to cause readers to be curious and to
> find out where to find the answer by eliminating items which do not fit on
> the natural path to finding an answer....or part of the Socratic method of
> education.
>

The thing is, this is a mailing list. Asking a question and not
expecting someone to write something is a bit naïve. So my apologies,
but I couldn't quite resist it.
Besides, as you yourself say, I haven't actually answered this.


> Implicit in this question is the understanding of a random seed, where and
> why they [may|may not] be useful.

Of course.

Venkat P

unread,
Mar 22, 2011, 12:35:53 PM3/22/11
to lr-loa...@googlegroups.com, Floris Kraak, James Pulley
When I first came across it (many eons ago.. I must add) , It was kind of a surprising to discover the feature (Its in Scenario Run Time Settings). 99.99999% do not use it (or have not heard of it), but it should be very useful. There is probably a smart alec development manager who is going to ask you to ensure you select the same set of random values for your retest. I havent run into him yet, but know that I am ready if I ever do run into one...

John Crunk

unread,
Mar 22, 2011, 1:09:34 PM3/22/11
to lr-loa...@googlegroups.com
We use this all the time

Sent from my iPhone

prasenjit dutta

unread,
Mar 24, 2011, 11:48:06 AM3/24/11
to lr-loa...@googlegroups.com, John Crunk
what is the significance of this seed value?? what does it actually represents???
Prasenjit

MikeTheBike

unread,
Mar 25, 2011, 2:04:19 PM3/25/11
to LoadRunner
It goes a long way to ensuring that your random numbers are actually
random. I like to feed in a time stamp value before calling the
random number generator. It might be overkill, but I'm satisfied that
I am getting as close to truly random values as possible.

Cheers,
Mike

Floris Kraak

unread,
Mar 25, 2011, 4:50:24 PM3/25/11
to lr-loa...@googlegroups.com, MikeTheBike
On Fri, Mar 25, 2011 at 7:04 PM, MikeTheBike <miket...@gmail.com> wrote:
> It goes a long way to ensuring that your random numbers are actually
> random.  I like to feed in a time stamp value before calling the
> random number generator.  It might be overkill, but I'm satisfied that
> I am getting as close to truly random values as possible.
>

If you want to see some overkill, look at
https://github.com/randakar/y-lib/blob/master/y_loadrunner_utils.c#L58
then :p

Kevyland

unread,
Mar 28, 2011, 11:29:25 AM3/28/11
to LoadRunner
Ah...someone recalls the term pseudo random. Inherit in all
computers.
Thus using a datetime stamp as a seed number helps in assuring a more
random random number.
> > represents???- Hide quoted text -
>
> - Show quoted text -

Floris Kraak

unread,
Mar 28, 2011, 12:47:07 PM3/28/11
to lr-loa...@googlegroups.com, Kevyland
On Mon, Mar 28, 2011 at 5:29 PM, Kevyland <kpe...@scholarshipamerica.org> wrote:
> Ah...someone recalls the term pseudo random.   Inherit in all
> computers.

That's actually not true.
The fact that loadrunner's random number generator is pseudo random
doesn't mean there can't be an implementation where the output of
rand() actually does contain a fair amount of randomness, or entropy.

Modern linux kernels for instance go to a lot of effort to mix various
hardware sources of entropy into the /dev/random device. Hardware
sources such as subtle variances in latencies in the CPU, which have
been shown to contain true randomness by academic researchers, network
behaviour, etc.


> Thus using a datetime stamp as a seed number helps in assuring a more
> random random number.

So yes, using a date/time stamp, the virtual user id, and the virtual
user group to seed the number generator in loadrunner does give you
more variation in the output of the random number generator, but it
doesn't actually help give you a truly random set of numbers. It's
still an algorithm at work. For true randomness you really do need to
resort to more elaborate measures.

Luckily I have never needed true randomness in LR so far :)

Reply all
Reply to author
Forward
0 new messages