Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Execute a function/method 30% of the iterations

Options
  • 25-02-2013 9:52pm
    #1
    Closed Accounts Posts: 3,981 ✭✭✭


    Hey there,

    Long story short, I have a bunch of web requests which I need to execute a certain percentage of the time.

    When I look at overall traffic I see a certain web request is called 30% of the time.

    I want to mimic this in C preferably but really I'm just trying to figure out the algorithm so any language will do.

    To simplify this:
    URL A is called 30% of the time.
    URL B is called 20% of the time.
    URL C is called 10 % of the time.
    URL D is called 40% of the time.

    Should I simply count from 0 to 99 and use the modulus function? I have 27 different URLs, ranging from 0.000047% up to 30%.

    Sorry, my brain is absolutely fried as I'm at the end of a 12 hour day without any breaks.


Comments

  • Moderators, Science, Health & Environment Moderators, Social & Fun Moderators, Society & Culture Moderators Posts: 60,097 Mod ✭✭✭✭Tar.Aldarion


    Do you want everything to run based on it's percentage is it, something like this?
    http://stackoverflow.com/questions/10610132/call-different-task-based-on-their-percentage


  • Registered Users Posts: 27,163 ✭✭✭✭GreeBo


    Use JMeter or an equivalent, call URL A 3 times, B twice, C once and D 4 times.
    Save that as an iteration/script/profile and then loop that as often as you want (or indefinitely if you are doing a soak test or something)

    GreeBo.


  • Closed Accounts Posts: 3,981 ✭✭✭[-0-]


    GreeBo wrote: »
    Use JMeter or an equivalent, call URL A 3 times, B twice, C once and D 4 times.
    Save that as an iteration/script/profile and then loop that as often as you want (or indefinitely if you are doing a soak test or something)

    GreeBo.

    Cheers GreeBo. I'm actually trying to perform this using LoadRunner, which is similar to JMeter. I'll see if it's possible to do it that way with LoadRunner. The guy before me just randomly picked a number between 0 and 255, and didn't seem to care how often each URL was hit.

    Cheers Tar - I'll look into that in the morning.


  • Moderators, Society & Culture Moderators Posts: 9,689 Mod ✭✭✭✭stevenmu


    [-0-] wrote: »
    To simplify this:
    URL A is called 30% of the time.
    URL B is called 20% of the time.
    URL C is called 10 % of the time.
    URL D is called 40% of the time.
    I'd pick a random number between 1 and 100. If it's between 1 and 30 I'd call URL A, if it's between 30 and 50 call URL B, between 50 and 60 call URL C, 60 to 100 call URL D. That should be pretty easy to abstract for arbitrary amounts of URLs, and should simulate a fairly natural load.


  • Closed Accounts Posts: 3,981 ✭✭✭[-0-]


    stevenmu wrote: »
    I'd pick a random number between 1 and 100. If it's between 1 and 30 I'd call URL A, if it's between 30 and 50 call URL B, between 50 and 60 call URL C, 60 to 100 call URL D. That should be pretty easy to abstract for arbitrary amounts of URLs, and should simulate a fairly natural load.

    I was wondering if that would work alright.

    The numbers have changed slightly, given the latest traffic.

    The most any URL is hit is 30%, then there is 21%, 19%, 10%, 5%, 1% and a bunch of 0.xxx%.

    I have some time today so I will give this method a whirl. I won't be completely accurate, but if I can get within a few percent it will be good enough.

    Thanks for all of the responses. I will let you guys know how it looks. :)


  • Advertisement
  • Moderators, Science, Health & Environment Moderators, Social & Fun Moderators, Society & Culture Moderators Posts: 60,097 Mod ✭✭✭✭Tar.Aldarion


    If it's 0.xxx use a bigger number, 1000, 10000 etc


Advertisement