minor improvements in stress tests
git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@379 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
parent
ab9b24f9d3
commit
8990ce6500
|
@ -21,6 +21,7 @@ import java.net.Socket;
|
|||
import java.util.Random;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
@ -44,7 +45,6 @@ public class AsyncStressTest extends TestCase
|
|||
protected InetAddress _addr;
|
||||
protected int _port;
|
||||
protected Random _random = new Random();
|
||||
protected int[] _loops;
|
||||
protected QueuedThreadPool _threads=new QueuedThreadPool();
|
||||
protected boolean _stress;
|
||||
|
||||
|
@ -54,6 +54,7 @@ public class AsyncStressTest extends TestCase
|
|||
_threads.setMaxThreads(50);
|
||||
_server.setThreadPool(_threads);
|
||||
_connector = new SelectChannelConnector();
|
||||
_connector.setMaxIdleTime(120000);
|
||||
_server.setConnectors(new Connector[]{ _connector });
|
||||
_server.setHandler(_handler);
|
||||
_server.start();
|
||||
|
@ -84,6 +85,8 @@ public class AsyncStressTest extends TestCase
|
|||
{
|
||||
socket[i] = new Socket(_addr,_port);
|
||||
socket[i].setSoTimeout(30000);
|
||||
if (i%10==0)
|
||||
Thread.sleep(50);
|
||||
if (i%80==0)
|
||||
System.err.println();
|
||||
System.err.print('+');
|
||||
|
@ -97,7 +100,7 @@ public class AsyncStressTest extends TestCase
|
|||
{
|
||||
int p=path[i][l]=_random.nextInt(__paths.length);
|
||||
|
||||
int period = _random.nextInt(490)+10;
|
||||
int period = _random.nextInt(290)+10;
|
||||
String uri=__paths[p][0].replace("<PERIOD>",Integer.toString(period));
|
||||
|
||||
long start=System.currentTimeMillis();
|
||||
|
@ -114,7 +117,7 @@ public class AsyncStressTest extends TestCase
|
|||
if (l%80==0)
|
||||
System.err.println();
|
||||
System.err.print('.');
|
||||
Thread.sleep(_random.nextInt(590)+10);
|
||||
Thread.sleep(_random.nextInt(290)+10);
|
||||
}
|
||||
|
||||
System.err.println();
|
||||
|
@ -160,7 +163,7 @@ public class AsyncStressTest extends TestCase
|
|||
}
|
||||
else
|
||||
{
|
||||
doConnections(80,40);
|
||||
doConnections(80,80);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.util.Queue;
|
|||
import java.util.Random;
|
||||
import java.util.Timer;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
@ -42,7 +43,7 @@ public class StressTest extends TestCase
|
|||
protected Connector _connector;
|
||||
protected InetAddress _addr;
|
||||
protected int _port;
|
||||
protected int[] _loops;
|
||||
protected volatile AtomicInteger[] _loops;
|
||||
protected QueuedThreadPool _threads=new QueuedThreadPool();
|
||||
protected boolean _stress;
|
||||
private ConcurrentLinkedQueue[] _latencies= {
|
||||
|
@ -203,17 +204,17 @@ public class StressTest extends TestCase
|
|||
{
|
||||
for (int i=0;i<loops;i++)
|
||||
{
|
||||
_loops[thread]=i;
|
||||
_loops[thread].set(i);
|
||||
doPaths(thread,name+"-"+i,persistent);
|
||||
Thread.sleep(1+_random.nextInt(10)*_random.nextInt(10));
|
||||
Thread.sleep(10);
|
||||
}
|
||||
_loops[thread]=loops;
|
||||
_loops[thread].set(loops);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
System.err.println(e);
|
||||
_loops[thread]=-_loops[thread];
|
||||
_loops[thread].set(-_loops[thread].get());
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
@ -246,9 +247,12 @@ public class StressTest extends TestCase
|
|||
};
|
||||
}
|
||||
|
||||
_loops=new int[threads];
|
||||
_loops=new AtomicInteger[threads];
|
||||
for (int i=0;i<threads;i++)
|
||||
{
|
||||
_loops[i]=new AtomicInteger(0);
|
||||
thread[i].start();
|
||||
}
|
||||
|
||||
String last=null;
|
||||
int same=0;
|
||||
|
@ -263,7 +267,7 @@ public class StressTest extends TestCase
|
|||
int total=0;
|
||||
for (int i=0;i<threads;i++)
|
||||
{
|
||||
int l=_loops[i];
|
||||
int l=_loops[i].get();
|
||||
if (l<0)
|
||||
{
|
||||
errors++;
|
||||
|
@ -355,7 +359,7 @@ public class StressTest extends TestCase
|
|||
doThreads(200,100,false);
|
||||
}
|
||||
else
|
||||
doThreads(25,50,false);
|
||||
doThreads(10,20,false);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue