| CODENOTIFIER | HelpYou are not signed inSign in |
Project: Jetty
Revision: 3594
Author: gregw
Date: 03 Sep 2008 19:58:40
Changes:| ... | ...@@ -34,14 +34,19 @@ | |
| 34 | 34 | |
| 35 | 35 | public class BayeuxLoadGenerator |
| 36 | 36 | { |
| 37 | final static String __DOTS="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-=+!@#$%^&*>"; | |
| 38 | ||
| 37 | 39 | SecureRandom _random= new SecureRandom(); |
| 38 | 40 | HttpClient http; |
| 39 | 41 | InetSocketAddress address; |
| 40 | 42 | ArrayList<BayeuxClient> clients=new ArrayList<BayeuxClient>(); |
| 43 | ||
| 44 | long _targetLatency; | |
| 41 | 45 | long _minLatency; |
| 42 | 46 | long _maxLatency; |
| 43 | 47 | long _totalLatency; |
| 44 | 48 | long _got; |
| 49 | long _over; | |
| 45 | 50 | AtomicInteger _subscribed = new AtomicInteger(); |
| 46 | 51 | |
| 47 | 52 | public BayeuxLoadGenerator() throws Exception |
| ... | ...@@ -92,6 +97,7 @@ | |
| 92 | 97 | int publish=1000; |
| 93 | 98 | int pause=100; |
| 94 | 99 | int burst=10; |
| 100 | _targetLatency=1000; | |
| 95 | 101 | int maxLatency=5000; |
| 96 | 102 | |
| 97 | 103 | System.err.print("base[/chat/demo]: "); |
| ... | ...@@ -113,6 +119,12 @@ | |
| 113 | 119 | rooms_per_client=Integer.parseInt(t); |
| 114 | 120 | |
| 115 | 121 | |
| 122 | System.err.print("target Latency ["+_targetLatency+"]: "); | |
| 123 | t = in.readLine().trim(); | |
| 124 | if (t.length()==0) | |
| 125 | t=""+_targetLatency; | |
| 126 | _targetLatency=Integer.parseInt(t); | |
| 127 | ||
| 116 | 128 | System.err.print("max Latency ["+maxLatency+"]: "); |
| 117 | 129 | t = in.readLine().trim(); |
| 118 | 130 | if (t.length()==0) |
| ... | ...@@ -171,6 +183,8 @@ | |
| 171 | 183 | if (_minLatency==0 || latency<_minLatency) |
| 172 | 184 | _minLatency=latency; |
| 173 | 185 | _totalLatency+=latency; |
| 186 | if (latency>_targetLatency) | |
| 187 | _over++; | |
| 174 | 188 | } |
| 175 | 189 | } |
| 176 | 190 | } |
| ... | ...@@ -238,6 +252,7 @@ | |
| 238 | 252 | _minLatency=0; |
| 239 | 253 | _maxLatency=0; |
| 240 | 254 | _totalLatency=0; |
| 255 | _over=0; | |
| 241 | 256 | } |
| 242 | 257 | |
| 243 | 258 | |
| ... | ...@@ -300,7 +315,8 @@ | |
| 300 | 315 | break trial; |
| 301 | 316 | } |
| 302 | 317 | |
| 303 | char dot=(char)('0'+(int)(latency/100)); | |
| 318 | int l=(int)(latency/100); | |
| 319 | char dot=l<__DOTS.length()?__DOTS.charAt(l):'~'; | |
| 304 | 320 | System.err.print(dot); |
| 305 | 321 | if (i%1000==0) |
| 306 | 322 | System.err.println(); |
| ... | ...@@ -338,7 +354,9 @@ | |
| 338 | 354 | |
| 339 | 355 | long end=System.currentTimeMillis(); |
| 340 | 356 | |
| 341 | System.err.println("Got "+_got+" at "+(_got*1000/(end-start))+"/s, latency min/ave/max ="+_minLatency+"/"+(_totalLatency/_got)+"/"+_maxLatency+"ms"); | |
| 357 | System.err.println("Got "+_got+" at "+(_got*1000/(end-start))+ | |
| 358 | "/s, latency min/ave/max ="+_minLatency+"/"+(_totalLatency/_got)+"/"+_maxLatency+"ms, "+ | |
| 359 | _over+" over "+_targetLatency+"ms"); | |
| 342 | 360 | } |
| 343 | 361 | |
| 344 | 362 | } |