SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 6 of 6
  1. #1
    Junior Member
    Join Date
    Jun 2008
    Posts
    29
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Random values generates duplicate instance

    Hi Everyone! Hava a great day!!!

    1. What version of LoadRunner (LR) or PerformanceCenter (PC) are you using? (specify which tool LR or PC)
    LR 9.0

    2. What is the protocol you are recording?
    Web(Html/Http)

    3. If HTML - are you using HTML-Advanced with URLs or,
    tried both

    4. If URL mode:
    - Concurrent groups, or
    - Without Concurrent groups?
    tried both

    5. Which LoadRunner/PerformanceCenter feature (FPs) or service packs are you using?
    (List details here)
    no

    6. VuGen Recording - are you using Old or New Recording Engine?
    new

    7. What kind of LoadRunner license do you have -
    - Permanent/limited

    Hi, I need some input:
    I'm trying the web based application, where i needs to click some random links. By using rand() function i've did it correctly.

    Here, consider i've 10 links to click. By using random values i'm going for 10 iteration. What i noticed here is, not all the 10links were visited( there are some repetative of random values.)

    My question here is:
    1. How to visit all links using random values in 10 iteration.(i don't want any repetation)

    Scenario2: Consider i've 3 links and 100 users I need to instruct my code such that first 30% of user should click the 1st link, next 30% of users should click only the 3rd link and last 40%of users should go for 2nd link.

    - How i need to instruct my code to recognize the % values. Is ther any specific function?

  2. #2
    Moderator JakeBrake's Avatar
    Join Date
    Dec 2000
    Location
    St. Louis - Year 2025
    Posts
    15,609
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Random values generates duplicate instance

    Look at the Code Share topic near the top of the LR forum. There are many pieces/parts/code fragments to help you.


    - ELSE -

    Study up on the runtime settings and run logic.

  3. #3
    Moderator
    Join Date
    Jan 2006
    Location
    Charlotte, NC
    Posts
    1,600
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Random values generates duplicate instance

    dhillar,

    To add to what Jake said and give you a specific answer to one of your questions...

    rand() generates a sequence of pseudo-random numbers. By mod'ing against "MAXVAL" you can generate a PR number between 0 and less than MAXVAL.

    Say your MAXVAL is 4 any of the following sequences are valid:

    0, 1, 2, 3
    0, 0, 0, 0
    1, 1, 3, 3
    3, 1, 2, 3

    etc.

    The whole point of rand() is that for any relatively finite sequence the numbers appear at random with no pattern discernable - especially not that each of your values will appear once!
    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!)

  4. #4
    Senior Member
    Join Date
    May 2005
    Location
    England
    Posts
    120
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Random values generates duplicate instance

    To answer your first question, I would never use truly random values in a test as it makes your test unscientific and unrepeatable. This may seem a bit pedantic but actual random values make it harder to debug race conditions, deadlocks and other synchronization problems because you can't cause the problem to happen on demand. If you use rand() then make sure you use the iteration and user number as a seed, not the time like it says in the help. Performance testing is a science!

    The simple solution is to generate a list of pseudo-random values in excel, then use this same input file each run. You can then assign blocks of multiples of ten rows to each user and be safe in the knowledge that you're running the same test each time.

    A programatic way of doing this would be to create an array of true/false (0/1) parameters or values to say if a slot has been used, plus a counter to say how many are available. When you use one up, decrease the counter and set the used flag to true. When pseudo-randomly selecting a slot, if the value has been used then move to the next slot and decrease the counter. If you reach the last slot then continue from the first. When the counter reaches 0, reset all your slots to false.
    04h

  5. #5
    SQA Knight
    Join Date
    Jul 1999
    Location
    Grand Rapids, MI
    Posts
    3,727
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Random values generates duplicate instance

    [ QUOTE ]
    1. How to visit all links using random values in 10 iteration.(i don't want any repetation)


    [/ QUOTE ]

    I wrote a general purpose randArray() function, unfortunately for you in vbScript syntax, to address the above issue. If you implement the function in C you then call the function with the iMin and iMax numbers and the function returns an array with with that range of numbers randomized. You then sequential access that array to get a non-duplicating index into your list of links, or an index into another array, etc.:

    http://www.sqaforums.com/showthreade...;Number=374294

    But, randomization is not very useful if you can't force your test to repeat the randomization, so you need to control the seed to the random number generator. Here again I can offer you commentary and vbScript code for QTP that discusses using a randomized number as the seed, with the ability to log that seed and use it to override a later test run to reproduce the random walk:

    http://www.sqaforums.com/showflat.ph...;Number=383875

    I hope you will find some of this useful in your efforts to randomize testing within each LoadRunner virtual user.

    Should you implement these functions in C, please share them on this forum as I am sure others will find them of value (I know I will).

    -Terry Horwath

  6. #6
    Moderator
    Join Date
    Aug 2001
    Location
    NC
    Posts
    6,018
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    Total Downloaded
    0

    Re: Random values generates duplicate instance

    Terry,

    A mechanism exists in the controller to set a seed for the randomization algorithm used by LoadRunner.
    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

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 10.00%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 04:35 AM.

Copyright BetaSoft Inc.