[prev in list] [next in list] [prev in thread] [next in thread] 

List:       grinder-use
Subject:    Re: [Grinder-use] Not able to run parallel.py which points to multiple scripts running form the same
From:       Philip Aston <philipa () mail ! com>
Date:       2012-10-10 21:04:23
Message-ID: 5075E2D7.5030204 () mail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


So to put it another way, the first 25 threads should randomly select
script1 or script2 for each run?

There's many of ways you could do this. Here's one:


# ..

|class| |TestRunner:|
|    ||def| |__init__(||self||):|
|        ||tid ||=| |grinder.threadNumber|

|        ||if| |tid < 25||:|||
|            def oneOrTheOther(runners ||||[||||createTestRunner("script1"||)||,
||||createTestRunner("script2"||)||]||||||):
                return random.choice(runners||])

|
|            ||self||.testRunner ||=| |oneOrTheOther|||


|    ||# This method is called for every run.|
|    ||def| |__call__(||self||):|
|        ||self||.testRunner()|


- Phil


On 09/10/12 00:29, pmallur wrote:
> Phil,
>
> I am running currently the grinder scripts setup somehow like the below,
> below but I see that the requests all run in a sequence. How can I make the
> request to be random mix.
> For Example I have scripts=["script","script2"]
> if tid <25 then run script0
> else script1
> whihc mean for every run the first 25 htreads are run by only script1.
> Rather I would like to see if there is a way to have both script1 and script
> 2 run in the first 25 htreads..
>
> Thanks
> Nima
>
>
> Philip Aston-2 wrote:
>>
>> The sample just partitions the thread ID into 4 values {0,1,2,3} and
>> uses that to allocate a quarter of the threads to script 1, a quarter to
>> script 2, and the rest to script 0:
>>
>>         if tid % 4 == 2:
>>             self.testRunner = createTestRunner(scripts[1])
>>         elif tid % 4 == 3:
>>             self.testRunner = createTestRunner(scripts[2])
>>         else:
>>             self.testRunner = createTestRunner(scripts[0])
>>
>> In your case, splitting the threads into twentyiths (units of 5% of the
>> thread count) would work:
>>
>>         partition = grinder.threadNumber % 20
>>         if partition < 10:
>>             self.testRunner = createTestRunner(scripts[0])
>>         elif partition < 14:
>>             self.testRunner = createTestRunner(scripts[1])
>>         elif partition < 17:
>>             self.testRunner = createTestRunner(scripts[2])
>>         else:
>>             self.testRunner = createTestRunner(scripts[3])
>>
>> Alternatively, if you want to work in percentiles:
>>
>>         percentile = (grinder.threadNumber * 100) /
>> grinder.properties["grinder.threads"]
>>         if partition < 50:
>>             self.testRunner = createTestRunner(scripts[0])
>>         elif partition < 70:
>>             self.testRunner = createTestRunner(scripts[1])
>>         elif partition < 85:
>>             self.testRunner = createTestRunner(scripts[2])
>>         else:
>>             self.testRunner = createTestRunner(scripts[3])
>>
>> - Phil
>>
>> On 25/09/12 14:26, pmallur wrote:
>>> Hi Phil,
>>>
>>> I was able to get the Sample Script for the Sequence.py running., but I
>>> would like to understand what is the number 4 in the script.
>>>
>>> If i were to have
>>> grinder.threads@
>>> grinder.runs 
>>>
>>>
>>> test.script.percent.script1P
>>> test.script.percent.script2 
>>> test.script.percent.script3
>>> test.script.percent.script4
>>>
>>> how would i reqrite this in the sample sequence script given in the
>>> examples
>>> directory.
>>>
>>> Thanks
>>> Nima
>>>
>>>
>>>
>>> pmallur wrote:
>>>> Hi Phil,
>>>>
>>>> I am trying to run parallel.py which points to more than 1 script
>>>> running
>>>> from the same machine. When I try to run it I keep getting " no module
>>>> named foo" but if I have the grinder.script=foo then it works.
>>>>
>>>> Can you tell me if there is a way to get more than one foo running on
>>>> the
>>>> same machine in Grinder-3.6
>>>>
>>>> previosuly in Grinder3.0 I have something like this
>>>> test.script.percent.foo1P
>>>> test.script.percent.foo2%
>>>> test.script.percent.foo3%
>>>>
>>>> Can the above be possible in grinder-3.6
>>>>
>>>> thanks
>>>> Nima
>>>>
>>>>


[Attachment #5 (text/html)]

<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">So to put it another way, the first 25
      threads should randomly select script1 or script2 for each run?<br>
      <br>
      There's many of ways you could do this. Here's one:<br>
      <br>
      <br>
      # ..<br>
      <br>
      <div class="line number15 index14 alt2"><code class="python
          keyword">class</code> <code class="python plain">TestRunner:</code></div>
      <div class="line number16 index15 alt1"><code class="python
          spaces">        </code><code class="python keyword">def</code> <code
          class="python plain">__init__(</code><code class="python
          color1">self</code><code class="python plain">):</code></div>
      <div class="line number17 index16 alt2"><code class="python
          spaces">                </code><code class="python plain">tid </code><code
          class="python keyword">=</code> <code class="python plain">grinder.threadNumber</code></div>
      <div class="line number18 index17 alt1">  </div>
      <div class="line number19 index18 alt2"><code class="python
          spaces">                </code><code class="python keyword">if</code>
        <code class="python plain">tid &lt; 25</code><code class="python
          plain">:<code class="python plain"></code></code><br>
        <code class="python plain">                     def oneOrTheOther(runners
          = </code><code class="python plain"><code class="python
            plain"><code class="python plain">[</code><code
              class="python plain"><code class="python plain"><code
                  class="python plain">createTestRunner("script1"</code><code
                  class="python plain">)</code></code>, </code><code
              class="python plain"><code class="python plain"><code
                  class="python plain">createTestRunner("script2"</code><code
                  class="python plain">)</code></code>]</code></code><code
            class="python plain"><code class="python plain"></code></code>):<br>
                                      return random.choice(runners</code><code
          class="python plain">])<br>
                                      <br>
        </code></div>
      <div class="line number20 index19 alt1"><code class="python
          spaces">                        </code><code class="python color1">self</code><code
          class="python plain">.testRunner </code><code class="python
          keyword">=</code> <code>oneOrTheOther</code><code
          class="python plain"></code></div>
      <br>
        
      <div class="line number26 index25 alt1"><code class="python
          spaces">        </code><code class="python comments"># This method
          is called for every run.</code></div>
      <div class="line number27 index26 alt2"><code class="python
          spaces">        </code><code class="python keyword">def</code> <code
          class="python plain">__call__(</code><code class="python
          color1">self</code><code class="python plain">):</code></div>
      <div class="line number28 index27 alt1"><code class="python
          spaces">                </code><code class="python color1">self</code><code
          class="python plain">.testRunner()</code></div>
      <br>
      <br>
      - Phil<br>
      <br>
      <br>
      On 09/10/12 00:29, pmallur wrote:<br>
    </div>
    <blockquote cite="mid:34530079.post@talk.nabble.com" type="cite">
      <pre wrap="">
Phil,

I am running currently the grinder scripts setup somehow like the below,
below but I see that the requests all run in a sequence. How can I make the
request to be random mix.
For Example I have scripts=["script","script2"]
if tid &lt;25 then run script0
else script1
whihc mean for every run the first 25 htreads are run by only script1.
Rather I would like to see if there is a way to have both script1 and script
2 run in the first 25 htreads..

Thanks
Nima


Philip Aston-2 wrote:
</pre>
      <blockquote type="cite">
        <pre wrap="">

The sample just partitions the thread ID into 4 values {0,1,2,3} and
uses that to allocate a quarter of the threads to script 1, a quarter to
script 2, and the rest to script 0:

        if tid % 4 == 2:
            self.testRunner = createTestRunner(scripts[1])
        elif tid % 4 == 3:
            self.testRunner = createTestRunner(scripts[2])
        else:
            self.testRunner = createTestRunner(scripts[0])

In your case, splitting the threads into twentyiths (units of 5% of the
thread count) would work:

        partition = grinder.threadNumber % 20
        if partition &lt; 10:
            self.testRunner = createTestRunner(scripts[0])
        elif partition &lt; 14:
            self.testRunner = createTestRunner(scripts[1])
        elif partition &lt; 17:
            self.testRunner = createTestRunner(scripts[2])
        else:
            self.testRunner = createTestRunner(scripts[3])

Alternatively, if you want to work in percentiles:

        percentile = (grinder.threadNumber * 100) /
grinder.properties["grinder.threads"]
        if partition &lt; 50:
            self.testRunner = createTestRunner(scripts[0])
        elif partition &lt; 70:
            self.testRunner = createTestRunner(scripts[1])
        elif partition &lt; 85:
            self.testRunner = createTestRunner(scripts[2])
        else:
            self.testRunner = createTestRunner(scripts[3])

- Phil

On 25/09/12 14:26, pmallur wrote:
</pre>
        <blockquote type="cite">
          <pre wrap="">Hi Phil,

I was able to get the Sample Script for the Sequence.py running., but I
would like to understand what is the number 4 in the script.

If i were to have
grinder.threads@
grinder.runs 


test.script.percent.script1P
test.script.percent.script2 
test.script.percent.script3
test.script.percent.script4

how would i reqrite this in the sample sequence script given in the
examples
directory.

Thanks
Nima



pmallur wrote:
</pre>
          <blockquote type="cite">
            <pre wrap="">Hi Phil,

I am trying to run parallel.py which points to more than 1 script
running
from the same machine. When I try to run it I keep getting " no module
named foo" but if I have the grinder.script=foo then it works.

Can you tell me if there is a way to get more than one foo running on
the
same machine in Grinder-3.6

previosuly in Grinder3.0 I have something like this
test.script.percent.foo1P
test.script.percent.foo2%
test.script.percent.foo3%

Can the above be possible in grinder-3.6

thanks
Nima


</pre>
          </blockquote>
        </blockquote>
      </blockquote>
    </blockquote>
    <br>
  </body>
</html>


------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev

_______________________________________________
grinder-use mailing list
grinder-use@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/grinder-use


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic