Results 1 to 7 of 7
  1. #1

    random number generator code

    Can any one give me code that can generate random numbers in vugen. i have tried rand() function ,Sepa_Tem_%m%d%H%M%S.000 in the parameter but they are failing as both of them are not generating random enough.as 70 users are running the test and number generated once must not be generated again as it searches for the previous generated records

  2. #2

    Re: random number generator code


    You need to be clearer on what you are trying to do.

    For random numbers you have three choices:

    1. Use the random parameter that is built into LR.

    2. Use the rand() function.

    3. Obtain code from the internet to generate random numbers.
    Unless you are writing a compiler, strtok is NOT the answer.
    See: http://www.sqaforums.com/showflat.ph...=541641#542222

    QAF is still an exercise in self-sufficiency! (Thank JB!)

  3. #3

    Re: random number generator code

    remember to use srand(time(NULL)); at the start if the script, not each iteration to seed the random number generator

    things that will help the random numbers being generated be more random

    slow ramp up (as the srand seeding will happen over a period of time)

    think time (especially between each random number being generated)

  4. #4

    Re: random number generator code

    as you have imposed a uniqueness and use once constraint then you will be forced into a different model rather than the use of a random number generator. While the ones available in LoadRunner are 'approximately uniform for large numbers of samples' there is still an opportunity for duplication.

    Pre-generate your random numbers into a file. Remove duplicates. Re-generate to fill in the number you need for your number of iterations * your number of users. Be sure to include your ramp up window in your number of iterations. Assign the block size manually. End your virtual user when all of your block samples are exhausted.
    James Pulley

    Replace ineffective offshore contracts, LoadRunnerByTheHour. Starting @ $19.95/hr USD.

    Put us to the test, skilled expertise is less expensive than you might imagine.

    Twitter: @LoadRunnerBTH @PerfBytes

  5. #5

    Re: random number generator code

    I'm with James, you've actually not thought through the solution to your problem and should redesign to accommodate the possibility for the same number coming up twice.

    This isn't hard - you could just use a datetime stamp with the vuserid appended onto the end and voila, you have an absolutely unique value that (assuming you use enough characters) will remain unique for more than a millennium.

    Don't like long messy numbers? Base64 encode the string and you get a much shorter but equally unique value.

  6. #6

    Re: random number generator code

    I would echo the sentiments of everyone else on this thread.

    I'd also add that depending on your requirements (which you haven't totally outlined) you may even be able to get away with doing less and it could potentially make sense.

    For example, I generate a 10-digit "random" number for an account. At 10 digits, there are 10 billion options for an account number. In my opinion, you may not need to check for duplicates if your number is sufficiently large. On the off chance a duplicate is entered you can either 1) put error handling in the script to handle it or 2) simply fail (are all your users as flawless as your script will be?)

    That maximizes your scripting output while still maintaining the integrity of a good performance test. But again, it all depends on the specifics.

  7. #7

    Re: random number generator code

    If you cant reuse a number that is used, Y dont you use Unique Number parameter. I guess that should be simple enough.




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
BetaSoft Inc.
All times are GMT -8. The time now is 03:40 PM.

Copyright BetaSoft Inc.